In this post I’ll provide an overview of how to split windows in VIM.
Split a windowSplitting an existing VIM window can be performed either horizontally or vertically.
Horizontal window splitting:sp /path/to/file or :split /path/to/file will split the current window horizontally.
Alternatively you can also use the key stroke combination CTRL+W s to split the current window horizontally. Note: If no path to a file is provided, the current window’s content will be show in the new split window as well.
Vertical window splitting:vs /path/to/file or :vsplit /path/to/file will split the current window vertically.
Alternatively you can also use the key stroke combination CTRL+W v to split the current window vertically.
Closing an existing split windowTo close the current split window type the quit command :q .
Moving the cursor from one split window to another CTRL+w [h or left direction key] move the cursor to the window to the left. E.g. CTRL+w h will move the cursor to the left window. CTRL+w [j or down direction key] move the cursor to the window below. CTRL+w [k or up direction key] move the cursor to the window above. CTRL+w [l or right direction key] move the cursor to the window to the right. CTRL+w w will move to the next bottom/right window, and then top/left when it moves from the bottom/right window. As a result holding down CTRL and repeatedly typing w is an easy way to cycle through all current windows. Resizing a split window CTRL+w [N+] Increase the current height by the value of N. If no number is provided for the value of N the height is increased by 1. E.g. CTRL+w 10+ would increase the height by 10. CTRL+w [N-] Decrease the current height by the value of N. E.g. CTRL+w 10- would decrease the height by 10. CTRL+w [N>] Increase the current width by the value of N. E.g. CTRL+w 10> would increase the width by 10. CTRL+w [N<] Decrease the current width by the value of N. E.g. CTRL+w 10< would decrease the width by 10. CTRL+w = Resize windows equally. CTRL+w | Maximize the current window’s width. Reposition a split window CTRL+w H CTRL+w J CTRL+w K CTRL+w L Extra HelpWant to learn more about splitting windows in VIM? Then check out the help file by typing :h windows.txt .