Vim Tips Wiki
(Move categories to tip template)
(Remove html character entities)
Line 19: Line 19:
 
au!
 
au!
 
set guifont=Andale_Mono:h12
 
set guifont=Andale_Mono:h12
:map <F7> :set guifont=Andale_Mono:h12<CR>
+
:map <F7> :set guifont=Andale_Mono:h12<CR>
:map &lt;S-F7&gt; :set guifont=Andale_Mono:h10&lt;CR&gt;
+
:map &lt;S-F7> :set guifont=Andale_Mono:h10<CR>
:map &lt;C-F7&gt; :set guifont=Andale_Mono:h14&lt;CR&gt;
+
:map <C-F7> :set guifont=Andale_Mono:h14<CR>
:map &lt;F9&gt; :set lines+=5&lt;CR&gt;
+
:map <F9> :set lines+=5<CR>
:map &lt;S-F9&gt; :set lines-=5&lt;CR&gt;
+
:map &lt;S-F9> :set lines-=5<CR>
:map &lt;C-F9&gt; :set lines=60&lt;CR&gt;
+
:map <C-F9> :set lines=60<CR>
:map &lt;M-F9&gt; :set lines=30&lt;CR&gt;
+
:map <M-F9> :set lines=30<CR>
:map &lt;F8&gt; :set columns+=10&lt;CR&gt;
+
:map <F8> :set columns+=10<CR>
:map &lt;S-F8&gt; :set columns-=10&lt;CR&gt;
+
:map &lt;S-F8> :set columns-=10<CR>
:map &lt;C-F8&gt; :set columns=132&lt;CR&gt;
+
:map <C-F8> :set columns=132<CR>
:map &lt;M-F8&gt; :set columns=80&lt;CR&gt;
+
:map <M-F8> :set columns=80<CR>
 
augroup END
 
augroup END
 
</pre>
 
</pre>
Line 75: Line 75:
   
 
----
 
----
Addition: I use &lt;Ctrl&gt; plus Cursor Keys to resize the current window relative to the neighbour window of a splitted screen.
+
Addition: I use <Ctrl> plus Cursor Keys to resize the current window relative to the neighbour window of a splitted screen.
   
 
<pre>
 
<pre>
 
' resize horzontal split window
 
' resize horzontal split window
nmap &lt;C-Left&gt; &lt;C-W&gt;-&lt;C-W&gt;-
+
nmap <C-Left> <C-W>-<C-W>-
nmap &lt;C-Right&gt; &lt;C-W&gt;+&lt;C-W&gt;+
+
nmap <C-Right> <C-W>+<C-W>+
 
' resize vertical split window
 
' resize vertical split window
nmap &lt;C-Up&gt; &lt;C-W&gt;&gt;&lt;C-W&gt;&gt;
+
nmap <C-Up> <C-W>><C-W>>
nmap &lt;C-Down&gt; &lt;C-W&gt;&lt;&lt;C-W&gt;&lt;
+
nmap <C-Down> <C-W><<C-W><
 
</pre>
 
</pre>
   

Revision as of 08:50, 29 September 2008

Tip 507 Printable Monobook Previous Next

created July 10, 2003 · complexity basic · author Tom Slee · version 5.7


These key mappings (placed in your vimrc) let you use the F8 and F9 keys to make a window wider or taller. The shift key reverses the effect, and the Ctrl and Alt modifiers go to a choice of standard settings. Mappings to change the font size.(which work slightly differently) are also included. Obviously you can change F8 and F9 to keys of your choice.

" Window size appearance
augroup guiappearance
  au!
  set guifont=Andale_Mono:h12
  :map <F7> :set guifont=Andale_Mono:h12<CR>
  :map <S-F7> :set guifont=Andale_Mono:h10<CR>
  :map <C-F7> :set guifont=Andale_Mono:h14<CR>
  :map <F9> :set lines+=5<CR>
  :map <S-F9> :set lines-=5<CR>
  :map <C-F9> :set lines=60<CR>
  :map <M-F9> :set lines=30<CR>
  :map <F8> :set columns+=10<CR>
  :map <S-F8> :set columns-=10<CR>
  :map <C-F8> :set columns=132<CR>
  :map <M-F8> :set columns=80<CR>
augroup END

Comments

Window resizing can also be done at window-manager level, so that it will work for all applications. In my case .fluxbox/keys contains:

# window sizing
Mod4 m :MaximizeWindow
Mod1 Mod4 h :HorizontalDecrement
Mod1 Mod4 j :VerticalIncrement
Mod1 Mod4 k :VerticalDecrement
Mod1 Mod4 l :HorizontalIncrement

# window movement
Mod4 h :BigNudgeLeft
Mod4 j :BigNudgeDown
Mod4 k :BigNudgeUp
Mod4 l :BigNudgeRight

As you can see, I used the familiar vim movement keys.

I mapped mod4 to the windows-key on my keyboard. To achieve this, you will need to put the following lines in ~/.Xmodmap:

! alt keys (explicitly configured, without this section meta doesn't work)
keycode 64 = Alt_L
add mod1 = Alt_L
keycode 113 = Alt_R
add mod1 = Alt_R

! ms flag keys
keycode 115 = Meta_L
keycode 116 = Meta_R
add mod4 = Meta_L
add mod4 = Meta_R

There is an amazingly intutitive script replacement, called "mouse". Although I wouldn't use it for each cursor movement, I would definitely use it in this particular case, rather than keys bound by some scripts.


Addition: I use <Ctrl> plus Cursor Keys to resize the current window relative to the neighbour window of a splitted screen.

' resize horzontal split window
nmap <C-Left> <C-W>-<C-W>-
nmap <C-Right> <C-W>+<C-W>+
' resize vertical split window
nmap <C-Up> <C-W>><C-W>>
nmap <C-Down> <C-W><<C-W><