Skip to Content
Learning the vi and Vim Editors, 7th Edition
book

Learning the vi and Vim Editors, 7th Edition

by Arnold Robbins, Elbert Hannah, Linda Lamb
July 2008
Beginner
492 pages
16h
English
O'Reilly Media, Inc.
Content preview from Learning the vi and Vim Editors, 7th Edition

Opening Windows

This section goes into depth about how to get the precise behavior you want when you split your window.

New Windows

As discussed previously, the simplest way to open a new window is to issue :split (for a horizontal division) or :vsplit (for a vertical division). A more in-depth discussion of the many commands and variations follows. We also include a command synopsis for quick reference.

Options During Splits

The full :split command to open a new horizontal window is:

:[n]split [++opt] [+cmd] [file]

where:

n

Tells Vim how many lines to display in the new window, which goes at the top.

opt

Passes Vim option information to the new window session (note that it must be preceded by two plus signs).

cmd

Passes a command for execution in the new window (note that it must be preceded by a single plus sign).

file

Specifies a file to edit in the new window.

For example, suppose you are editing a file and want to split the window to edit another file named otherfile. You want to ensure that the session uses a fileformat of unix (which ensures the use of a line feed to end each line instead of a carriage return and line feed combination). Finally, you want the window to be 15 lines tall. Enter:

:15split ++fileformat=unix otherfile

To simply split the screen, showing the same file in both windows and using all the current defaults, you can use the key commands ^Ws, ^WS, or ^W^S.

Tip

If you want windows to always split equally, set the equalalways option, preferably putting it in your .vimrc to ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning the vi and Vim Editors, 8th Edition

Learning the vi and Vim Editors, 8th Edition

Arnold Robbins, Elbert Hannah
Vim Masterclass

Vim Masterclass

Jason Cannon
Mastering Vim

Mastering Vim

Ruslan Osipov

Publisher Resources

ISBN: 9780596529833Errata Page