Tip 39: Divide Your Workspace into Split Window
Return to the top: <<Practical Vim>>
-
a window is a viewport onto a buffer
References
# If you open the file in vim,
# then you can \"ayy@a the next line to execute the vim command:
:h window
Creating Split Windows
Command
|
Effect
|
<C-w>S
|
Split the current window horizontally, reusing the current buffer in the new window
|
<C-w>v
|
Split the current window vertically, reusing the current buffer in the new window
|
:sp[lit] {file}
|
Split the current window horizontally, loading {file} into the new window
|
:vsp[lit] {file}
|
Split the current window vertically, loading {file} into the new window
|
Changing the Focus Between Windows
Command
|
Effect
|
<C-w>w
|
Cycle between open windows
|
<C-w>h
|
Focus the window to the left
|
<C-w>j
|
Focus the window below
|
<C-w>k
|
Focus the window above
|
<C-w>l
|
Focus the window to the right
|
-
<C-w><C-w>
: equivalent to <C-w>w
References:
# If you open the file in vim,
# then you can \"ayy@a the next line to execute the vim command:
:h window-move-cursor
-
use mouse in gvim (check the 'mouse' option)
References:
# If you open the file in vim,
# then you can \"ayy@a the next line to execute the vim command:
:h 'mouse'
Closing Windows
Ex Command
|
Normal Command
|
Effect
|
:cl[ose]
|
<C-w>c
|
Close the active window
|
:on[ly]
|
<C-w>o
|
Keep only the active window, closing all others
|
Resizing and Rearranging Windows
Keystrokes
|
Buffer Contents
|
<C-w>=
|
Equalize width and height of all windows
|
<C-w>_
|
Maximize height of the active window
|
<C-w>|
|
Maximize width of the active window
|
[N]<C-w>_
|
Set active window height to [N] rows
|
[N]<C-w>|
|
Set active window width to [N] columns
|
References:
# If you open the file in vim,
# then you can \"ayy@a the next line to execute the vim command:
:h window-resize
Rearranging windows
References:
# If you open the file in vim,
# then you can \"ayy@a the next line to execute the vim command:
:h window-moving