Learning the vi Editor

Learning the vi EditorSearch this book
Previous: 10.4 InitializationChapter 10
elvis
Next: 10.6 GUI Interfaces
 

10.5 Multiwindow Editing

To create a new window in elvis, you use the ex :split command. You then use one of the regular ex commands, such as :e filename or :n to edit a new file. This is the simplest method; other, shorter methods are described below. You can switch back and forth between windows with [CTRL-W][CTRL-W].

<preface id="VI6-CH-0">
<title>Preface </title>

<para>
Text editing is one of the most common uses of any computer system, and
<command>vi</command> is one of the most useful standard text editors
on your system.
With <command>vi</command> you can create new files, or edit any
existing UNIX text file.
_____________________________________________________________________
# Makefile for vi book
#
# Arnold Robbins

CHAPTERS = ch00_6.sgm ch00_5.sgm ch00.sgm ch01.sgm ch02.sgm ch03.sgm \
        ch04.sgm ch05.sgm ch06.sgm ch07.sgm ch08.sgm
APPENDICES = appa.sgm appb.sgm appc.sgm appd.sgm

POSTSCRIPT = ch00_6.ps ch00_5.ps ch00.ps ch01.ps ch02.ps ch03.ps \
        ch04.ps ch05.ps ch06.ps ch07.ps ch08.ps \
        appa.ps appb.ps appc.ps appd.ps

The split screen is the result of typing elvis ch00.sgm followed by :split Makefile.

Like nvi, elvis gives each window its own status line. elvis is unique in that it uses a highlighted line of underscores, instead of reverse video, for the status line. ex colon commands are carried out on each window's status line.

Table 10.1 describes the windowing ex mode commands and what they do.


Table 10.1: elvis Window Management Commands
CommandFunction
sp[lit] [file]

Create a new window; load it with file if supplied. Otherwise, the new window shows the current file.

new

Create a new empty buffer, and then create a new window to show that buffer.

sne[w]
sn[ext] [file...]

Create a new window, showing the next file in the argument list. The current file is not affected.

sN[ext]

Create a new window, showing the previous file in the argument list. The current file is not affected.

sre[wind][!]

Create a new window, showing the first file in the argument list. Reset the "current" file to be the first one with respect to the :next command. The current file is not affected.

sl[ast]

Create a new window, showing the last file in the argument list. The current file is not affected.

sta[g][!] tag

Create a new window showing the file where the requested tag is found.

sa[ll]

Create a new window for any files named in the argument list that don't already have a window.

wi[ndow] [target]

With no target, list all windows. The possible values for target are described in Table 10.2.

close

Close the current window. The buffer that the window was displaying remains intact. If it was modified, the other elvis commands that quit will prevent you from quitting until you explicitly save or discard the buffer.

wquit

Write the buffer back to the file and close the window. The file is saved whether or not it has been modified.

qall

Issues a :q command for each window. Buffers without windows are not affected.

Table 10.2 describes the windowing ex arguments and their meanings.


Table 10.2: Arguments to the elvis Window command
ArgumentMeaning
+

Switch to the next window, like ^W k.

++

Switch to the next window, wrapping like ^W ^W.

-

Switch to the previous window, like ^W j.

--

Switch to the previous window, wrapping.

num

Switch to the window whose windowid=num.

buffer-name

Switch to the window editing the named buffer.

elvis provides a number of vi mode commands for moving between windows. They are summarized in Table 10.3.


Table 10.3: elvis Window Commands from vi Command Mode
CommandFunction
^W c

Hide the buffer and close the window. This is identical to the :close command.

^W d

Toggle the display mode between "normal" and the buffer's usual display mode. This is a per-window option. Display modes are discussed in Section 10.10.1, "Display Modes".

^W j

Move down to the next window.

^W k

Move up to the previous window.

^W n

Create a new window, and create a new buffer to be displayed in the window. It is similar to the :snew command.

^W q

Save the buffer and close the window, identical to ZZ.

^W s

Split the current window, equivalent to :split.

^W S

Toggle the wrap option. This option controls whether long lines wrap, or whether the whole screen scrolls to the right. This is a per-window option. This option is discussed in Section 10.8.5, "Left-Right Scrolling" later in this chapter.

^W ]

Create a new window, then look up the tag underneath the cursor. It is similar to the :stag command.

[count] ^W ^W

Move to next window, or to the countth window.

^W +

Increase the size of the current window (termcap interface only).

^W -

Reduce the size of the current window (termcap interface only).

^W \

Make the current window as large as possible (termcap interface only).


Previous: 10.4 InitializationLearning the vi EditorNext: 10.6 GUI Interfaces
10.4 InitializationBook Index10.6 GUI Interfaces

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System