Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | .Go 2 "VISUAL MODE COMMANDS" |
2 | .PP | |
3 | Most visual mode commands are one keystroke long. | |
4 | The following table lists the operation performed by each keystroke, | |
5 | and also denotes any options or arguments that it accepts. | |
6 | Notes at the end of the table describe the notation used in this table. | |
7 | .PP | |
8 | In addition to the keys listed here, your keyboard's "arrow" keys | |
9 | will be interpretted as the appropriate cursor movement commands. | |
10 | The same goes for <PgUp> and <PgDn>, if your keyboard has them. | |
11 | The <Insert> key will toggle between insert mode and replace mode. | |
12 | There is a colon mode command (":map", to be described later) | |
13 | which will allow you to define other keys, such as function keys. | |
14 | .PP | |
15 | A tip: visual command mode looks a lot like text input mode. | |
16 | If you forget which mode you're in, just hit the <Esc> key. | |
17 | If \*E beeps, then you're in visual command mode. | |
18 | If \*E does not beep, then you were in input mode, | |
19 | but by hitting <Esc> you will have switched to visual command mode. | |
20 | So, 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) | |
27 | count ^D Scroll down <count> lines (default 1/2 screen) | |
28 | count ^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 # | |
31 | count ^H Move left, like h (MOVE) | |
32 | ^I --- | |
33 | count ^J Move down (MOVE) | |
34 | ^K --- | |
35 | ^L Redraw the screen | |
36 | count ^M Move to the front of the next line (MOVE) | |
37 | count ^N Move down (MOVE) | |
38 | ^O --- | |
39 | count ^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 --- | |
44 | count ^U Scroll up <count> lines (default 1/2 screen) | |
45 | ^V --- | |
46 | ^W --- | |
47 | count ^X Move to a physical column number on the screen (MOVE) (EXT) | |
48 | count ^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 | ^_ --- | |
55 | count 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 | |
58 | count # \s'-2'+\s'+2' Increment a number (EDIT) (EXT) | |
15637ed4 RG |
59 | $ Move to the rear of the current line (MOVE) |
60 | count % Move to matching (){}[] or to a given % of file (MOVE) (EXT) | |
61 | count & Repeat the previous ":s//" command here (EDIT) | |
78ed81a3 | 62 | ' \s'-2'key\s'+2' Move to a marked line (MOVE) |
15637ed4 RG |
63 | count ( Move backward <count> sentences (MOVE) |
64 | count ) Move forward <count> sentences (MOVE) | |
65 | * Go to the next error in the errlist (EXT) | |
66 | count + Move to the front of the next line (MOVE) | |
67 | count , Repeat the previous [fFtT] but in the other direction (MOVE) | |
68 | count - Move to the front of the preceding line (MOVE) | |
69 | count . 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 | 82 | count ; 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 | |
88 | count A \s'-2'inp\s'+2' Append at end of the line (EDIT) | |
15637ed4 | 89 | count 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) |
92 | count E Move end of Word (MOVE) | |
78ed81a3 | 93 | count F \s'-2'key\s'+2' Move leftward to a given character (MOVE) |
15637ed4 RG |
94 | count G Move to line #<count> (default is the bottom line) (MOVE) |
95 | count H Move to home row (the line at the top of the screen) | |
78ed81a3 | 96 | count I \s'-2'inp\s'+2' Insert at the front of the line (after indents) (EDIT) |
15637ed4 RG |
97 | count J Join lines, to form one big line (EDIT) |
98 | K Look up keyword (EXT) | |
99 | count 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 | 102 | count 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) |
106 | count S \s'-2'inp\s'+2' Change lines, like <count>cc | |
107 | count 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) | |
110 | count W Move forward <count> Words (MOVE) | |
111 | count X Delete the character(s) to the left of the cursor (EDIT) | |
112 | count 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) | |
118 | count _ Move to the current line | |
78ed81a3 | 119 | ` \s'-2'key\s'+2' Move to a marked character (MOVE) |
120 | count a \s'-2'inp\s'+2' Insert text after the cursor (EDIT) | |
15637ed4 | 121 | count 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 | 124 | count e Move forward to the end of the current word (MOVE) |
78ed81a3 | 125 | count f \s'-2'key\s'+2' Move rightward to a given character (MOVE) |
15637ed4 RG |
126 | g --- |
127 | count h Move left (MOVE) | |
78ed81a3 | 128 | count i \s'-2'inp\s'+2' Insert text at the cursor (EDIT) |
15637ed4 RG |
129 | count j Move down (MOVE) |
130 | count k Move up (MOVE) | |
131 | count 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 | 134 | count 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 | 137 | count r \s'-2'key\s'+2' Replace <count> chars by a given character (EDIT) |
138 | count s \s'-2'inp\s'+2' Replace <count> chars with text from the user (EDIT) | |
139 | count 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) | |
142 | count w Move forward <count> words (MOVE) | |
143 | count 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 |
146 | count { Move back <count> paragraphs (MOVE) |
147 | count | Move to column <count> (the leftmost column is 1) | |
148 | count } Move forward <count> paragraphs (MOVE) | |
149 | count ~ 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 |
153 | Many commands may be preceded by a count. This is a sequence of digits |
154 | representing a decimal number. For most commands that use a count, | |
155 | the command is repeated <count> times. The count is always optional, | |
156 | and usually defaults to 1. | |
78ed81a3 | 157 | .IP key 0.7i |
15637ed4 RG |
158 | Some commands require two keystrokes. The first key always determines |
159 | which command is to be executed. The second key is used as a parameter | |
160 | to the command. | |
78ed81a3 | 161 | .IP mv 0.7i |
15637ed4 RG |
162 | Some commands (! < > c d y \\ =) operate on text between the cursor and some |
163 | other position. | |
164 | There are three ways that you can specifify that other position. | |
78ed81a3 | 165 | .IP "" 0.7i |
15637ed4 RG |
166 | The first way is to follow the command keystroke with a movement command. |
167 | For example, "dw" deletes a single word. | |
168 | "d3w" and "3dw" both delete three words. | |
78ed81a3 | 169 | .IP "" 0.7i |
15637ed4 RG |
170 | The second way is to type the command keystroke twice. |
171 | This causes whole lines to be acted upon. | |
172 | For example, ">>" indents the current line. | |
173 | "3>>" indents the current line and the following two lines. | |
78ed81a3 | 174 | .IP "" 0.7i |
15637ed4 RG |
175 | The last way is to move the cursor to one end of the text, |
176 | type 'v' or 'V' to start marking, | |
177 | move the cursor to the other end, | |
178 | and then type the desired command key. | |
78ed81a3 | 179 | .IP inp 0.7i |
15637ed4 RG |
180 | Many commands allow the user to interactively enter text. |
181 | See the discussion of "input mode" in the following section. | |
78ed81a3 | 182 | .IP (EXT) 0.7i |
15637ed4 | 183 | These commands are extensions -- the real vi doesn't have them. |
78ed81a3 | 184 | .IP (EDIT) 0.7i |
15637ed4 | 185 | These commands affect text, and may be repeated by the "." command. |
78ed81a3 | 186 | .IP (MOVE) 0.7i |
15637ed4 RG |
187 | These commands move the cursor, and may be used to specify the extent |
188 | of a member of the "mv" class of commands. | |
189 | .NH 2 | |
190 | Input Mode | |
191 | .PP | |
192 | You can't type text into your file directly from visual command mode. | |
193 | Instead, you must first give a command which will put you into input mode. | |
194 | The commands to do this are A/C/I/O/R/S/a/i/o/s. | |
195 | .PP | |
196 | The S/s/C/c commands temporarily place a $ at the end of the text that | |
197 | they are going to change. | |
198 | .PP | |
199 | In input mode, all keystrokes are inserted into the text at the | |
200 | cursor'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 | |
218 | Also, on some systems, ^S may stop output, ^Q may restart output, | |
219 | and ^C may interupt execution. | |
220 | ^@ (the NUL character) cannot be inserted. | |
221 | .PP | |
222 | The R visual command puts you in overtype mode, | |
223 | which is a slightly different form of input mode. | |
224 | In overtype mode, each time you insert a character, | |
225 | one of the old characters is deleted from the file. | |
226 | .NH 2 | |
227 | Arrow keys in Input Mode | |
228 | .PP | |
229 | The 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.) | |
231 | The <PgUp>, <PgDn>, <Home>, and <End> keys work in input mode, too. | |
232 | The <Delete> key deletes a single character in input mode. | |
233 | The <Insert> key toggles between input mode and replace mode. | |
234 | .PP | |
235 | The best thing about allowing arrow keys to work in input mode is that | |
236 | as long as you're in input mode, | |
237 | \*E seems to have a fairly ordinary user interface. | |
238 | With most other text editors, you are always in either insert mode or | |
239 | replace mode, and you can use the arrow keys at any time to move the cursor. | |
240 | Now, \*E can act like that, too. | |
241 | In fact, with the new "inputmode" option and the "control-Z control-Z" input | |
242 | command, you may never have to go into visual command mode for simple edit | |
243 | sessions. | |
244 | .NH 2 | |
245 | Digraphs | |
246 | .PP | |
247 | \*E supports digraphs as a way to enter non-ASCII characters. | |
248 | A digraph is a character which is composed of two other characters. | |
249 | For example, an apostrophe and the letter i could be defined as a digraph | |
250 | which is to be stored & displayed as an accented i. | |
251 | .PP | |
252 | There is no single standard for extended ASCII character sets. | |
253 | \*E can be compiled to fill the digraph with values appropriate for | |
254 | either the IBM PC character set, or the LATIN-1 character set used by | |
255 | X windows, or neither. | |
256 | (See the discussions of -DCS_IBMPC and -DCS_LATIN1 in the CFLAGS section | |
257 | of this manual.) | |
258 | You can view or edit the digraph table via the ":digraph" colon command. | |
259 | .PP | |
260 | Digraphs will not be recognized until you've entered ":set digraph". | |
261 | .PP | |
262 | To actually use a digraph | |
263 | type the first character, then hit <Backspace>, and then type the | |
264 | second character. | |
265 | \*E will then substitute the non-ASCII character in their place. | |
266 | .NH 2 | |
267 | Abbreviations | |
268 | .PP | |
269 | \*E can expand abbreviations for you. | |
270 | You define an abbreviation with the :abbr command, | |
271 | and then whenever you type in the abbreviated form while in input mode, | |
272 | \*E will immediately replace it with the long form. | |
273 | COBOL programmers should find this useful. :-) | |
274 | .PP | |
275 | \*E doesn't perform the substitution until you type a non-alphanumeric | |
276 | character to mark the end of the word. | |
277 | If you type a control-V before that non-alphanumeric character, then | |
278 | \*E will not perform the substitution. | |
279 | .NH 2 | |
280 | Auto-Indent | |
281 | .PP | |
282 | With the ":set autoindent" option turned on, | |
283 | \*E will automatically insert leading whitespace at the beginning of each | |
284 | new line that you type in. | |
285 | The leading whitespace is copied from the preceding line. | |
286 | .PP | |
287 | To add more leading whitespace, type control-T. | |
288 | To remove some whitespace, type control-D. | |
289 | .PP | |
290 | If you ":set noautotab", then the whitespace generated by control-T will | |
291 | always consist of spaces -- never tabs. | |
292 | Some people seem to prefer this. | |
293 | .PP | |
294 | \*E' autoindent mode isn't 100% compatible with vi's. | |
295 | In \*E, 0^D and ^^D don't work, | |
296 | ^U can wipeout all indentation, | |
297 | and sometimes \*E will use a different amount of indentation than vi would. |