This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.0'.
[unix-history] / usr.bin / elvis / doc / visual.ms
CommitLineData
15637ed4
RG
1.Go 2 "VISUAL MODE COMMANDS"
2.PP
3Most visual mode commands are one keystroke long.
4The following table lists the operation performed by each keystroke,
5and also denotes any options or arguments that it accepts.
6Notes at the end of the table describe the notation used in this table.
7.PP
8In addition to the keys listed here, your keyboard's "arrow" keys
9will be interpretted as the appropriate cursor movement commands.
10The same goes for <PgUp> and <PgDn>, if your keyboard has them.
11The <Insert> key will toggle between insert mode and replace mode.
12There is a colon mode command (":map", to be described later)
13which will allow you to define other keys, such as function keys.
14.PP
15A tip: visual command mode looks a lot like text input mode.
16If you forget which mode you're in, just hit the <Esc> key.
17If \*E beeps, then you're in visual command mode.
18If \*E does not beep, then you were in input mode,
19but by hitting <Esc> you will have switched to visual command mode.
20So, one way or another, after <Esc> \*E will be ready for a command.
21.LD
22.ta 0.7i 1.3i
78ed81a3 23\s'+2'COMMAND DESCRIPTION\s'-2'
15637ed4
RG
24 ^A Search for next occurence of word at cursor (MOVE)(EXT)
25 ^B Move toward the top of the file by 1 screenful
26 ^C --- (usually sends SIGINT, to interupt a command)
27count ^D Scroll down <count> lines (default 1/2 screen)
28count ^E Scroll up <count> lines
29 ^F Move toward the bottom of the file by 1 screenful
30 ^G Show file status, and the current line #
31count ^H Move left, like h (MOVE)
32 ^I ---
33count ^J Move down (MOVE)
34 ^K ---
35 ^L Redraw the screen
36count ^M Move to the front of the next line (MOVE)
37count ^N Move down (MOVE)
38 ^O ---
39count ^P Move up (MOVE)
40 ^Q --- (typically XON, which restarts screen updates)
41 ^R Redraw the screen
42 ^S --- (typically XOFF, which stops screen updates)
43 ^T ---
44count ^U Scroll up <count> lines (default 1/2 screen)
45 ^V ---
46 ^W ---
47count ^X Move to a physical column number on the screen (MOVE) (EXT)
48count ^Y Scroll down <count> lines
49 ^Z --- (sometimes sends SIGSUSP, to suspend execution)
50 ESC ---
51 ^\\ --- (usually sends SIGQUIT, which is ignored)
52 ^] If the cursor is on a tag name, go to that tag
53 ^^ Switch to the previous file, like ":e #"
54 ^_ ---
55count SPC Move right,like l (MOVE)
78ed81a3 56 ! \s'-2'mv\s'+2' Run the selected lines thru an external filter program
57 " \s'-2'key\s'+2' Select which cut buffer to use next
58count # \s'-2'+\s'+2' Increment a number (EDIT) (EXT)
15637ed4
RG
59 $ Move to the rear of the current line (MOVE)
60count % Move to matching (){}[] or to a given % of file (MOVE) (EXT)
61count & Repeat the previous ":s//" command here (EDIT)
78ed81a3 62 ' \s'-2'key\s'+2' Move to a marked line (MOVE)
15637ed4
RG
63count ( Move backward <count> sentences (MOVE)
64count ) Move forward <count> sentences (MOVE)
65 * Go to the next error in the errlist (EXT)
66count + Move to the front of the next line (MOVE)
67count , Repeat the previous [fFtT] but in the other direction (MOVE)
68count - Move to the front of the preceding line (MOVE)
69count . Repeat the previous "edit" command
78ed81a3 70 / \s'-2'text\s'+2' Search forward for a given regular expression (MOVE)
15637ed4
RG
71 0 If not part of count, move to 1st char of this line (MOVE)
72 1 Part of count
73 2 Part of count
74 3 Part of count
75 4 Part of count
76 5 Part of count
77 6 Part of count
78 7 Part of count
79 8 Part of count
80 9 Part of count
78ed81a3 81 : \s'-2'text\s'+2' Run single EX cmd
15637ed4 82count ; Repeat the previous [fFtT] cmd (MOVE)
78ed81a3 83 < \s'-2'mv\s'+2' Shift text left (EDIT)
84 = \s'-2'mv\s'+2' Reformat
85 > \s'-2'mv\s'+2' Shift text right (EDIT)
86 ? \s'-2'text\s'+2' Search backward for a given regular expression (MOVE)
87 @ \s'-2'key\s'+2' Execute the contents of a cut-buffer as VI commands
88count A \s'-2'inp\s'+2' Append at end of the line (EDIT)
15637ed4 89count B Move back Word (MOVE)
78ed81a3 90 C \s'-2'inp\s'+2' Change text from the cursor through the end of the line (EDIT)
15637ed4
RG
91 D Delete text from the cursor through the end of the line (EDIT)
92count E Move end of Word (MOVE)
78ed81a3 93count F \s'-2'key\s'+2' Move leftward to a given character (MOVE)
15637ed4
RG
94count G Move to line #<count> (default is the bottom line) (MOVE)
95count H Move to home row (the line at the top of the screen)
78ed81a3 96count I \s'-2'inp\s'+2' Insert at the front of the line (after indents) (EDIT)
15637ed4
RG
97count J Join lines, to form one big line (EDIT)
98 K Look up keyword (EXT)
99count L Move to last row (the line at the bottom of the screen)
100 M Move to middle row
101 N Repeat previous search, but in the opposite direction (MOVE)
78ed81a3 102count O \s'-2'inp\s'+2' Open up a new line above the current line (EDIT)
15637ed4
RG
103 P Paste text before the cursor (EDIT)
104 Q Quit to EX mode
78ed81a3 105 R \s'-2'inp\s'+2' Overtype (EDIT)
106count S \s'-2'inp\s'+2' Change lines, like <count>cc
107count T \s'-2'key\s'+2' Move leftward *almost* to a given character (MOVE)
15637ed4
RG
108 U Undo all recent changes to the current line
109 V Start marking lines for c/d/y/</>/!/\\ (EXT)
110count W Move forward <count> Words (MOVE)
111count X Delete the character(s) to the left of the cursor (EDIT)
112count Y Yank text line(s) (copy them into a cut buffer)
113 Z Z Save the file & exit
114 [ [ Move back 1 section (MOVE)
78ed81a3 115 \\ \s'-2'mv\s'+2' Pop-up menu for modifying text (EXT)
15637ed4
RG
116 ] ] Move forward 1 section (MOVE)
117 ^ Move to the front of the current line (after indent) (MOVE)
118count _ Move to the current line
78ed81a3 119 ` \s'-2'key\s'+2' Move to a marked character (MOVE)
120count a \s'-2'inp\s'+2' Insert text after the cursor (EDIT)
15637ed4 121count b Move back <count> words (MOVE)
78ed81a3 122 c \s'-2'mv\s'+2' Change text (EDIT)
123 d \s'-2'mv\s'+2' Delete text (EDIT)
15637ed4 124count e Move forward to the end of the current word (MOVE)
78ed81a3 125count f \s'-2'key\s'+2' Move rightward to a given character (MOVE)
15637ed4
RG
126 g ---
127count h Move left (MOVE)
78ed81a3 128count i \s'-2'inp\s'+2' Insert text at the cursor (EDIT)
15637ed4
RG
129count j Move down (MOVE)
130count k Move up (MOVE)
131count l Move right (MOVE)
78ed81a3 132 m \s'-2'key\s'+2' Mark a line or character
15637ed4 133 n Repeat the previous search (MOVE)
78ed81a3 134count o \s'-2'inp\s'+2' Open a new line below the current line (EDIT)
15637ed4
RG
135 p Paste text after the cursor (EDIT)
136 q ---
78ed81a3 137count r \s'-2'key\s'+2' Replace <count> chars by a given character (EDIT)
138count s \s'-2'inp\s'+2' Replace <count> chars with text from the user (EDIT)
139count t \s'-2'key\s'+2' Move rightward *almost* to a given character (MOVE)
15637ed4
RG
140 u Undo the previous edit command
141 v Start marking characters for c/d/y/</>/!/\\ (EXT)
142count w Move forward <count> words (MOVE)
143count x Delete the character that the cursor's on (EDIT)
78ed81a3 144 y \s'-2'mv\s'+2' Yank text (copy it into a cut buffer)
145 z \s'-2'key\s'+2' Scroll current line to the screen's +=top -=bottom .=middle
15637ed4
RG
146count { Move back <count> paragraphs (MOVE)
147count | Move to column <count> (the leftmost column is 1)
148count } Move forward <count> paragraphs (MOVE)
149count ~ Switch a character between uppercase & lowercase (EDIT)
150 DEL --- (usually mapped to shift-X, so it deletes one character)
151.DE
78ed81a3 152.IP count 0.7i
15637ed4
RG
153Many commands may be preceded by a count. This is a sequence of digits
154representing a decimal number. For most commands that use a count,
155the command is repeated <count> times. The count is always optional,
156and usually defaults to 1.
78ed81a3 157.IP key 0.7i
15637ed4
RG
158Some commands require two keystrokes. The first key always determines
159which command is to be executed. The second key is used as a parameter
160to the command.
78ed81a3 161.IP mv 0.7i
15637ed4
RG
162Some commands (! < > c d y \\ =) operate on text between the cursor and some
163other position.
164There are three ways that you can specifify that other position.
78ed81a3 165.IP "" 0.7i
15637ed4
RG
166The first way is to follow the command keystroke with a movement command.
167For example, "dw" deletes a single word.
168"d3w" and "3dw" both delete three words.
78ed81a3 169.IP "" 0.7i
15637ed4
RG
170The second way is to type the command keystroke twice.
171This causes whole lines to be acted upon.
172For example, ">>" indents the current line.
173"3>>" indents the current line and the following two lines.
78ed81a3 174.IP "" 0.7i
15637ed4
RG
175The last way is to move the cursor to one end of the text,
176type 'v' or 'V' to start marking,
177move the cursor to the other end,
178and then type the desired command key.
78ed81a3 179.IP inp 0.7i
15637ed4
RG
180Many commands allow the user to interactively enter text.
181See the discussion of "input mode" in the following section.
78ed81a3 182.IP (EXT) 0.7i
15637ed4 183These commands are extensions -- the real vi doesn't have them.
78ed81a3 184.IP (EDIT) 0.7i
15637ed4 185These commands affect text, and may be repeated by the "." command.
78ed81a3 186.IP (MOVE) 0.7i
15637ed4
RG
187These commands move the cursor, and may be used to specify the extent
188of a member of the "mv" class of commands.
189.NH 2
190Input Mode
191.PP
192You can't type text into your file directly from visual command mode.
193Instead, you must first give a command which will put you into input mode.
194The commands to do this are A/C/I/O/R/S/a/i/o/s.
195.PP
196The S/s/C/c commands temporarily place a $ at the end of the text that
197they are going to change.
198.PP
199In input mode, all keystrokes are inserted into the text at the
200cursor's position, except for the following:
201.ID
202^A insert a copy of the last input text
203^D delete one indent character
204^H (backspace) erase the character before the cursor
205^L redraw the screen
206^M (carriage return) insert a newline (^J, linefeed)
207^O execute next key as a visual command (limited!)
208^P insert the contents of the cut buffer
209^R redraw the screen, like ^L
210^T insert an indent character
211^U backspace to the beginning of the line
212^V insert the following keystroke, even if special
213^W backspace to the beginning of the current word
214^Z^Z write the file & exit \*E
215^[ (ESCape) exit from input mode, back to command mode
216.DE
217.PP
218Also, on some systems, ^S may stop output, ^Q may restart output,
219and ^C may interupt execution.
220^@ (the NUL character) cannot be inserted.
221.PP
222The R visual command puts you in overtype mode,
223which is a slightly different form of input mode.
224In overtype mode, each time you insert a character,
225one of the old characters is deleted from the file.
226.NH 2
227Arrow keys in Input Mode
228.PP
229The arrow keys can be used to move the cursor in input mode.
230(This is an extension; the real Vi doesn't support arrow keys in input mode.)
231The <PgUp>, <PgDn>, <Home>, and <End> keys work in input mode, too.
232The <Delete> key deletes a single character in input mode.
233The <Insert> key toggles between input mode and replace mode.
234.PP
235The best thing about allowing arrow keys to work in input mode is that
236as long as you're in input mode,
237\*E seems to have a fairly ordinary user interface.
238With most other text editors, you are always in either insert mode or
239replace mode, and you can use the arrow keys at any time to move the cursor.
240Now, \*E can act like that, too.
241In fact, with the new "inputmode" option and the "control-Z control-Z" input
242command, you may never have to go into visual command mode for simple edit
243sessions.
244.NH 2
245Digraphs
246.PP
247\*E supports digraphs as a way to enter non-ASCII characters.
248A digraph is a character which is composed of two other characters.
249For example, an apostrophe and the letter i could be defined as a digraph
250which is to be stored & displayed as an accented i.
251.PP
252There is no single standard for extended ASCII character sets.
253\*E can be compiled to fill the digraph with values appropriate for
254either the IBM PC character set, or the LATIN-1 character set used by
255X windows, or neither.
256(See the discussions of -DCS_IBMPC and -DCS_LATIN1 in the CFLAGS section
257of this manual.)
258You can view or edit the digraph table via the ":digraph" colon command.
259.PP
260Digraphs will not be recognized until you've entered ":set digraph".
261.PP
262To actually use a digraph
263type the first character, then hit <Backspace>, and then type the
264second character.
265\*E will then substitute the non-ASCII character in their place.
266.NH 2
267Abbreviations
268.PP
269\*E can expand abbreviations for you.
270You define an abbreviation with the :abbr command,
271and then whenever you type in the abbreviated form while in input mode,
272\*E will immediately replace it with the long form.
273COBOL programmers should find this useful. :-)
274.PP
275\*E doesn't perform the substitution until you type a non-alphanumeric
276character to mark the end of the word.
277If you type a control-V before that non-alphanumeric character, then
278\*E will not perform the substitution.
279.NH 2
280Auto-Indent
281.PP
282With the ":set autoindent" option turned on,
283\*E will automatically insert leading whitespace at the beginning of each
284new line that you type in.
285The leading whitespace is copied from the preceding line.
286.PP
287To add more leading whitespace, type control-T.
288To remove some whitespace, type control-D.
289.PP
290If you ":set noautotab", then the whitespace generated by control-T will
291always consist of spaces -- never tabs.
292Some people seem to prefer this.
293.PP
294\*E' autoindent mode isn't 100% compatible with vi's.
295In \*E, 0^D and ^^D don't work,
296^U can wipeout all indentation,
297and sometimes \*E will use a different amount of indentation than vi would.