VIM Command for a Split Window


Vi Improved, commonly called Vim, is a powerful command-line text editor for UNIX-like operating systems. Vim is designed with the philosophy that users should never have to leave the home row of the keyboard to accomplish tasks. With that in mind, everything can be accomplished in Vim, including the modification of its interface, with a few keystrokes. Of course, this also means that simple tasks, such as splitting windows, can be done in many different ways.

Splitting Horizontally

  • By default, Vim will split windows horizontally. This can be done by exiting the Insert mode with the "ESC" key, then typing ":sp", ":split", or the "CTRL"+"W" and "N" keystroke combination. Additionally, a file path and name can follow the ":sp" or ":split" commands to open the file in the new window's buffer for editing, otherwise a blank buffer will appear and you will have to use the ":e" command to open a file for editing.

Splitting Vertically

  • Many documents are better examined by splitting the windows vertically. This can be done with the ":vsp" or ":vsplit" commands. Like with a regular split, buffers can be automatically populated with a file for editing by appending a file path and name to the command. Applications such as vimdiff, for comparing files in Vim, utilize vertical splits when comparing two or more files.

Continual Splitting

  • Often times, there is a need to open several files for comparison. A single mode or split might not be the best solution for viewing a lot of complex code on a single screen. With window splitting in Vim, you can split a window vertically for example, then split the new window horizontally, making two small buffer one over the other and one large buffer to the right. You can use this to organize code or have documentation handy while writing a complex piece of a program.

Working With Splits

  • Creating a split is just the beginning in Vim. There are several commands for moving around in and editing split windows. Working with windows, often called viewports depending on who you ask, all centers around the "CTRL"+"W" key combination. Moving through the viewports use the combination, plus a direction to move. The "+" and "-" symbols will resize the windows manually, while the "=" sign will make all windows an equal size.

Related Searches


Promoted By Zergnet


Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!