Intro to Vim Tip #6 (Multiple viewports)
One feature of vim I don’t use enough is the ability to split the screen and view multiple files at once. I use this feature all the time when I use vimdiff, but not really any other time. I thought I’d take a moment to lay out some uses of it (thank Linux.com for the reference):
From Command Mode:
- :sp splits the screen horizontally
- :vsp splits the screen vertically
- Ctrl-w Ctrl-w moves between viewports
- Ctrl-w [right arrow] moves active viewport 1 to the right
- Ctrl-w [left arrow] moves active viewport 1 to the left
- Ctrl-w 3[left arrow] moves active viewport 3 to the left
- Ctrl-w q will close the active window.
and remember that you can open a file with
filename in the newly created viewport
Ctrl+w v also splits vertically
Ctrl+w _ maximizes the current window size
Ctrl+w = sets all windows to equal size
Ctrl+w 3+ increases the current window by 3 lines (assuming you have vertically split windows)
Ctrl+w 3- decreases the current window by 3 lines (assuming you have vertically split windows)