OK, normally, I don’t use vim windows, they are really tiles, so I normally use separate windows and tools like Divvy and Hammerspoon to move windows around. Still, it is sometimes good to be able to see multiple windows particularly if you want to copy and paste between them. I haven’t spent much time learning the various window commands with Ctrl-W or the Window command. So if here are the commands I’ve used. Note that many of the commands have a :
equivalent so you can say :vsplit a_new_file.py
and it splits and opens at the same time
- CTRL-W CTRL-S or Ctrl-W s. :split horizontally split with the current buffer so that you can look at two parts of the file
- Ctrl-W v or CTRL-W, CTRL-V. :vsplit vertically and you can look at two parts of the same file
- Ctrl-W n or CTRL-W CTRL-N:new horizontal split with an empty buffer so you can :e a new file
- Ctrl-W Ctrl-W or Ctrl-W w. This switch between the windows that are open, The Ctrl-W, Ctrl-W is nice because then you don’t need to release the control key.
- Ctrl-W CTRL-P or Ctrl-W p. Go to previous window
- Ctrl-W <arrow key>. To go to the left, right, above or lower windows
Then to get rid of windows
- Ctrl-W c. Close the window although
:bd
or buffer destroy also works - Ctrl-W o. Only leave the current windows open, close everything else
Here are some less used command that are helpful:
- Ctrl-W n. A new split for horizontally and then open a blank window
- Ctrl-W p. Previous