Commit | Line | Data |
---|---|---|
0d19c241 JH |
1 | .\" Copyright (c) 1994 |
2 | .\" The Regents of the University of California. All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms, with or without | |
5 | .\" modification, are permitted provided that the following conditions | |
6 | .\" are met: | |
7 | .\" 1. Redistributions of source code must retain the above copyright | |
8 | .\" notice, this list of conditions and the following disclaimer. | |
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer in the | |
11 | .\" documentation and/or other materials provided with the distribution. | |
12 | .\" 3. All advertising materials mentioning features or use of this software | |
13 | .\" must display the following acknowledgement: | |
14 | .\" This product includes software developed by the University of | |
15 | .\" California, Berkeley and its contributors. | |
16 | .\" 4. Neither the name of the University nor the names of its contributors | |
17 | .\" may be used to endorse or promote products derived from this software | |
18 | .\" without specific prior written permission. | |
19 | .\" | |
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
30 | .\" SUCH DAMAGE. | |
31 | .\" | |
304585c1 | 32 | .\" @(#)vi.1 8.3 (Berkeley) 3/19/94 |
0d19c241 | 33 | .\" |
304585c1 | 34 | .Dd "March 19, 1994" |
0d19c241 JH |
35 | .Dt EX/VI 1 |
36 | .Os | |
304585c1 | 37 | .Sh NAME |
0d19c241 JH |
38 | .Nm ex, vi, view |
39 | .Nd text editors | |
40 | .Sh SYNOPSIS | |
304585c1 AM |
41 | .Nm \&ex |
42 | .Op Fl eFlRsv | |
43 | .Op Fl c Ar cmd | |
0d19c241 JH |
44 | .Op Fl r Ar file |
45 | .Op Fl t Ar tag | |
46 | .Op Fl w Ar size | |
304585c1 AM |
47 | .Op Fl x Ar \&aw |
48 | .Op Ar "file ..." | |
49 | .Nm \&vi | |
0d19c241 | 50 | .Op Fl eFlRv |
304585c1 | 51 | .Op Fl c Ar cmd |
0d19c241 JH |
52 | .Op Fl r Ar file |
53 | .Op Fl t Ar tag | |
54 | .Op Fl w Ar size | |
304585c1 AM |
55 | .Op Fl x Ar \&aw |
56 | .Op Ar "file ..." | |
57 | .Nm view | |
58 | .Op Fl eFlRv | |
59 | .Op Fl c Ar cmd | |
0d19c241 JH |
60 | .Op Fl r Ar file |
61 | .Op Fl t Ar tag | |
62 | .Op Fl w Ar size | |
304585c1 AM |
63 | .Op Fl x Ar \&aw |
64 | .Op Ar "file ..." | |
0d19c241 | 65 | .Sh DESCRIPTION |
304585c1 AM |
66 | .Nm \&Vi |
67 | is a screen oriented text editor. | |
68 | .Nm \&Ex | |
0d19c241 | 69 | is a line-oriented text editor. |
304585c1 AM |
70 | .Nm \&Ex |
71 | and | |
72 | .Nm \&vi | |
73 | are different interfaces to the same program, | |
74 | and it is possible to switch back and forth during an edit session. | |
0d19c241 | 75 | .Nm View |
304585c1 | 76 | is the equivalent of using the |
0d19c241 JH |
77 | .Fl R |
78 | (read-only) option of | |
304585c1 | 79 | .Nm \&vi . |
0d19c241 JH |
80 | .Pp |
81 | This manual page is the one provided with the | |
304585c1 AM |
82 | .Nm ex/vi |
83 | versions of the | |
84 | .Nm ex/vi | |
85 | text editors. | |
86 | .Nm Ex/vi | |
0d19c241 JH |
87 | are intended as bug-for-bug compatible replacements for the original |
88 | Fourth Berkeley Software Distribution (4BSD) | |
304585c1 | 89 | .Nm \&ex |
0d19c241 | 90 | and |
304585c1 | 91 | .Nm \&vi |
0d19c241 | 92 | programs. |
304585c1 AM |
93 | For the rest of this manual page, |
94 | .Nm ex/vi | |
95 | is used only when it's necessary to distinguish it from the historic | |
96 | implementations of | |
97 | .Nm ex/vi . | |
98 | .Pp | |
99 | This manual page is intended for users already familiar with | |
100 | .Nm ex/vi . | |
101 | Anyone else should almost certainly read a good tutorial on the | |
102 | editor before this manual page. | |
103 | If you're in an unfamiliar environment, and you absolutely have to | |
104 | get work done immediately, read the section near the end of this | |
105 | manual page, entitled FAST STARTUP. | |
106 | It's probably enough to get you going. | |
0d19c241 JH |
107 | .Pp |
108 | The following options are available: | |
304585c1 | 109 | .Bl -tag -width Ds |
0d19c241 JH |
110 | .It Fl c |
111 | Execute | |
304585c1 | 112 | .Ar cmd |
0d19c241 | 113 | immediately after starting the edit session. |
304585c1 AM |
114 | Particularly useful for initial positioning in the file, however |
115 | .Ar cmd | |
0d19c241 JH |
116 | is not limited to positioning commands. |
117 | This is the POSIX 1003.2 interface for the historic | |
304585c1 | 118 | .Dq "+cmd" |
0d19c241 | 119 | syntax. |
304585c1 | 120 | .Nm Ex/vi |
0d19c241 JH |
121 | supports both the old and new syntax. |
122 | .It Fl e | |
304585c1 AM |
123 | Start editing in ex mode, as if the command name were |
124 | .Nm \&ex . | |
0d19c241 JH |
125 | .It Fl F |
126 | Don't copy the entire file when first starting to edit. | |
304585c1 AM |
127 | (The default is to make a copy in case someone else modifies |
128 | the file during your edit session.) | |
0d19c241 JH |
129 | .It Fl l |
130 | List the files that may be recovered using the | |
131 | .Fl r | |
132 | option of | |
304585c1 AM |
133 | .Nm \&vi . |
134 | This is the new interface for the historic syntax of the | |
0d19c241 | 135 | .Fl r |
304585c1 AM |
136 | option without a file argument. |
137 | .Nm Ex/vi | |
0d19c241 JH |
138 | supports both the old and new syntax. |
139 | .It Fl R | |
140 | Start editing in read-only mode, as if the command name was | |
304585c1 AM |
141 | .Nm view , |
142 | or the readonly option was set. | |
0d19c241 JH |
143 | .It Fl r |
144 | Recover the specified file. | |
145 | .It Fl s | |
146 | Enter batch mode; applicable only to | |
304585c1 | 147 | .Nm \&ex |
0d19c241 JH |
148 | edit sessions. |
149 | Batch mode is useful when running | |
304585c1 | 150 | .Nm \&ex |
0d19c241 | 151 | scripts. |
304585c1 AM |
152 | Prompts, informative messages and other user oriented message |
153 | are turned off, | |
154 | and no startup files or environmental variables are read. | |
0d19c241 | 155 | This is the POSIX 1003.2 interface for the historic |
304585c1 AM |
156 | .Dq \&\- |
157 | argument. | |
158 | .Nm \&Ex/vi | |
0d19c241 JH |
159 | supports both the old and new syntax. |
160 | .It Fl t | |
161 | Start editing at the specified tag. | |
162 | (See | |
163 | .Xr ctags 1 ). | |
164 | .It Fl w | |
165 | Set the initial window size to the specified number of lines. | |
166 | .It Fl v | |
167 | Start editing in vi mode, as if the command name was | |
304585c1 | 168 | .Nm \&vi |
0d19c241 JH |
169 | or |
170 | .Nm view . | |
171 | .It Fl x | |
172 | Reserved for X11 interfaces. | |
304585c1 AM |
173 | .Em "No X11 support is currently implemented." |
174 | .El | |
0d19c241 | 175 | .Pp |
304585c1 AM |
176 | .Nm Ex/vi |
177 | exit 0 on success, and greater than 0 if an error occurs. | |
178 | .Sh ENVIRONMENTAL VARIABLES | |
179 | .Bl -tag -width XXXX -compact | |
180 | .It Ev COLUMNS | |
181 | The number of columns on the screen. | |
182 | This value overrides any system or terminal specific values. | |
183 | If the COLUMNS environmental variable is not set when | |
184 | .Nm ex/vi | |
185 | runs, or the | |
186 | .Sy columns | |
187 | option is explicitly reset by the user, | |
188 | .Nm ex/vi | |
189 | enters the value into the environment. | |
190 | .It Ev EXINIT | |
191 | A list of | |
192 | .Nm \&ex | |
193 | startup commands. | |
194 | .It Ev HOME | |
195 | The user's home directory, used as the initial directory path | |
196 | for the startup | |
197 | .Pa $HOME/.exrc | |
198 | file. | |
199 | This value is also used as the default directory for the | |
200 | .Nm \&vi | |
201 | .Sy \&cd | |
0d19c241 | 202 | command. |
304585c1 AM |
203 | .It Ev LINES |
204 | The number of rows on the screen. | |
205 | This value overrides any system or terminal specific values. | |
206 | If the LINES environmental variable is not set when | |
207 | .Nm ex/vi | |
208 | runs, or the | |
209 | .Sy lines | |
210 | option is explicitly reset by the user, | |
211 | .Nm ex/vi | |
212 | enters the value into the environment. | |
213 | .It Ev SHELL | |
214 | The user's shell of choice (see also the | |
215 | .Sy shell | |
216 | option). | |
217 | .It Ev TERM | |
218 | The user's terminal type. | |
219 | The default is the type | |
220 | .Dq unknown . | |
221 | If the TERM environmental variable is not set when | |
222 | .Nm ex/vi | |
223 | runs, or the | |
224 | .Sy term | |
225 | option is explicitly reset by the user, | |
226 | .Nm ex/vi | |
227 | enters the value into the environment. | |
228 | .It Ev TMPDIR | |
229 | The location used to stored temporary files (see also the | |
230 | .Sy directory | |
231 | option). | |
232 | .El | |
233 | .Sh SET OPTIONS | |
234 | #include <set.opt.roff> | |
235 | .Sh FAST STARTUP | |
236 | This section will tell you the minimum amount that you need to | |
237 | do simple editing tasks using | |
238 | .Nm \&vi . | |
239 | If you've never used any screen editor before, you're likely to have | |
240 | problems even with this simple introduction. | |
241 | In that case you should find someone that already knows | |
242 | .Nm \&vi | |
243 | and have them walk you through this section. | |
0d19c241 | 244 | .Pp |
304585c1 AM |
245 | .Nm \&Vi |
246 | is a screen editor. | |
247 | This means that it takes up almost the entire screen, displaying part | |
248 | of the file on each screen line, except for the last line of the screen. | |
249 | The last line of the screen is used for you to give commands to | |
250 | .Nm \&vi , | |
251 | and for | |
252 | .Nm \&vi | |
253 | to give information to you. | |
0d19c241 | 254 | .Pp |
304585c1 AM |
255 | The other fact that you need to understand is that |
256 | .Nm \&vi | |
257 | is a modeful editor, i.e. you are either entering text or you | |
258 | are executing commands, and you have to be in the right mode | |
259 | to do one or the other. | |
260 | You will be in command mode when you first start editing a file. | |
261 | There are commands that switch you into input mode. | |
262 | There is only one key that takes you out of input mode, | |
263 | and that is the <escape> key. | |
264 | (Key names are written using less-than and greater-than signs, e.g. | |
265 | <escape> means the | |
266 | .Dq escape | |
267 | key, usually labeled | |
268 | .Dq esc | |
269 | on your terminal's keyboard.) | |
270 | If you're ever confused as to which mode you're in, | |
271 | keep entering the <escape> key until | |
272 | .Nm \&vi | |
273 | beeps at you. | |
274 | (Generally, | |
275 | .Nm \&vi | |
276 | will beep at you if you try and do something that's not allowed. | |
277 | It will also display error messages.) | |
0d19c241 | 278 | .Pp |
304585c1 AM |
279 | To start editing a file, enter the command |
280 | .Dq Li "vi file_name<carriage-return>" . | |
281 | The command you should enter as soon as you start editing is | |
282 | .Dq Li ":set verbose showmode<carriage-return>" . | |
283 | This will make the editor give you verbose error messages and display | |
284 | the current mode at the bottom of the screen. | |
0d19c241 | 285 | .Pp |
304585c1 AM |
286 | The commands to move around the file are: |
287 | .Bl -tag -width XXXX -compact | |
288 | .It Sy h | |
289 | Move the cursor left one character. | |
290 | .It Sy j | |
291 | Move the cursor down one line. | |
292 | .It Sy k | |
293 | Move the cursor up one line. | |
294 | .It Sy l | |
295 | Move the cursor right one character. | |
296 | .It Sy <cursor-arrows> | |
297 | The cursor arrow keys should work, too. | |
298 | .It Sy /text<carriage-return> | |
299 | Search for the string | |
300 | .Dq text | |
301 | in the file, and move the cursor to its first character. | |
302 | .El | |
303 | .Pp | |
304 | The commands to enter new text are: | |
305 | .Bl -tag -width XXXX -compact | |
306 | .It Sy a | |
307 | Append new text, | |
308 | .Em after | |
309 | the cursor. | |
310 | .It Sy i | |
311 | Insert new text, | |
312 | .Em before | |
313 | the cursor. | |
314 | .It Sy o | |
315 | Open a new line below the line the cursor is on, and start | |
316 | entering text. | |
317 | .It Sy O | |
318 | Open a new line above the line the cursor is on, and start | |
319 | entering text. | |
320 | .It Sy <escape> | |
321 | Once you've entered input mode using the one of the | |
322 | .Sy \&a , | |
323 | .Sy \&i , | |
324 | .Sy \&O , | |
325 | or | |
326 | .Sy \&o | |
327 | commands, use | |
328 | .Sy <escape> | |
329 | to quit entering text and return to command mode. | |
330 | .El | |
331 | .Pp | |
332 | The commands to copy text are: | |
333 | .Bl -tag -width XXXX -compact | |
334 | .It Sy yy | |
335 | Copy the line the cursor is on. | |
336 | .It Sy p | |
337 | Append the copied line after the line the cursor is on. | |
338 | .El | |
0d19c241 | 339 | .Pp |
304585c1 AM |
340 | The commands to delete text are: |
341 | .Bl -tag -width XXXX -compact | |
342 | .It Sy dd | |
343 | Delete the line the cursor is on. | |
344 | .It Sy x | |
345 | Delete the character the cursor is on. | |
346 | .El | |
347 | .Pp | |
348 | The commands to write the file are: | |
349 | .Bl -tag -width XXXX -compact | |
350 | .It Sy :w<carriage-return> | |
351 | Write the file back to the file with the name that you originally used | |
352 | as an argument on the | |
353 | .Nm \&vi | |
354 | command line. | |
355 | .It Sy :w file_name<carriage-return> | |
356 | Write the file back to the file with the name | |
357 | .Dq file_name . | |
358 | .El | |
359 | .Pp | |
360 | The commands to quit editing and exit the editor are: | |
361 | .Bl -tag -width XXXX -compact | |
362 | .It Sy :q<carriage-return> | |
363 | Quit editing and leave vi (if you've modified the file, but not | |
364 | saved your changes, | |
365 | .Nm \&vi | |
366 | will refuse to quit). | |
367 | .It Sy :q!<carriage-return> | |
368 | Quit, discarding any modifications that you may have made. | |
369 | .El | |
370 | .Pp | |
371 | One final caution. | |
372 | Unusual characters can take up more than one column on the screen, | |
373 | and long lines can take up more than a single screen line. | |
374 | The above commands work on | |
375 | .Dq physical | |
376 | characters and lines, i.e. they affect the entire line no matter | |
377 | how many screen lines it takes up and the entire character no matter | |
378 | how many screen columns it takes up. | |
379 | .Sh BUGS | |
0d19c241 | 380 | See the file |
304585c1 | 381 | .Pa vi/docs/bugs.current |
0d19c241 JH |
382 | for a list of the known bugs in this version. |
383 | .Sh FILES | |
304585c1 AM |
384 | .Bl -tag -width /var/tmp/vi.recover -compact |
385 | .It Pa /bin/sh | |
386 | The default user shell. | |
387 | .It Pa /etc/vi.exrc | |
388 | System-wide vi startup file. | |
0d19c241 | 389 | .It Pa /tmp |
304585c1 | 390 | Temporary file directory. |
0d19c241 | 391 | .It Pa /var/tmp/vi.recover |
304585c1 AM |
392 | Recovery file directory. |
393 | .It Pa $HOME/.exrc | |
394 | user's home directory startup file. | |
395 | .It Pa .exrc | |
396 | local directory startup file. | |
0d19c241 JH |
397 | .El |
398 | .Sh SEE ALSO | |
399 | .Xr ctags 1 , | |
400 | .Xr more 1 , | |
401 | .Xr curses 3 , | |
402 | .Xr dbopen 3 | |
403 | .sp | |
404 | The | |
178c26c5 | 405 | .Dq "Vi Quick Reference" |
0d19c241 JH |
406 | card. |
407 | .sp | |
178c26c5 | 408 | .Dq "An Introduction to Display Editing with Vi" , |
0d19c241 | 409 | found in the |
178c26c5 | 410 | .Dq "UNIX User's Manual Supplementary Documents" . |
0d19c241 | 411 | .sp |
178c26c5 | 412 | .Dq "Edit: A tutorial" , |
0d19c241 | 413 | found in the |
178c26c5 | 414 | .Dq "UNIX User's Manual Supplementary Documents" . |
0d19c241 | 415 | .sp |
304585c1 | 416 | .Dq "\&Ex Reference Manual (Version 3.7)" , |
0d19c241 | 417 | found in the |
178c26c5 JH |
418 | .Dq "UNIX User's Manual Supplementary Documents" . |
419 | .Pp | |
420 | .Nm Nroff/troff | |
421 | source for the previous three documents are distributed with | |
304585c1 | 422 | .Nm ex/vi |
178c26c5 | 423 | in the |
304585c1 | 424 | .Pa vi/docs/USD.doc |
178c26c5 | 425 | directory of the |
304585c1 | 426 | .Nm ex/vi |
178c26c5 | 427 | source code. |
0d19c241 JH |
428 | .sp |
429 | The files | |
304585c1 AM |
430 | .Dq autowrite , |
431 | .Dq input , | |
432 | .Dq quoting , | |
0d19c241 | 433 | and |
304585c1 | 434 | .Dq structures , |
0d19c241 | 435 | found in the |
304585c1 | 436 | .Pa vi/docs/internals |
0d19c241 | 437 | directory of the |
304585c1 | 438 | .Nm ex/vi |
0d19c241 JH |
439 | source code. |
440 | .Sh HISTORY | |
441 | The | |
0d19c241 | 442 | .Nm ex/vi |
304585c1 AM |
443 | replacements for the |
444 | .Nm ex/vi | |
445 | editor first appeared in 4.4BSD. | |
0d19c241 | 446 | .Sh STANDARDS |
304585c1 AM |
447 | .Nm \&Ex/vi |
448 | is close to IEEE Std1003.2 (``POSIX''). | |
449 | That document differs from historical | |
450 | .Nm ex/vi | |
451 | practice in several places; there are changes to be made on both sides. |