Professional Documents
Culture Documents
Izuchaem Redaktory VI I Vim 7-E Izd PDF
Izuchaem Redaktory VI I Vim 7-E Izd PDF
Izuchaem Redaktory VI I Vim 7-E Izd PDF
www.oreilly.com
US $34.99
CAN $34.99
ISBN: 978-0-596-52983-3
y(7IA5J6*PMTSNN(+\!%!&!}!;
Robbins,
Hannah
& Lamb
Vim
vi Vim
Now the default editor on most Linux systems and the default
version of vi on Mac OS X, Vim is also available for many other
operating systems. This guide teaches text-editing basics as well
as advanced tools, such as interactive macros and scripts to
extend the editorall in the easy-to-follow style thats made
this book a classic. Youll learn how to:
SEVENTH
EDITION
vi Vim
Learning
the vi andVim Editors
Seventh Edition
viVim
-
2013
vi Vim,
7-
.
.
.
.
.
.
.
.
., ., .
vi Vim, 7- . . . .: -,
2013. 512., .
ISBN 978-5-93286-200-1
30 vi UNIX Linux,
vi. UNIX , 30
, .
Vim vi.
. ,
vi Vim , Linux
UNIX.
, ,
,
. vi, ,
vi, vi
UNIX, Vim
,
Vim, Vim (gvim), Vim, . Vim vi: nvi, elvis vile.
ISBN 978-5-93286-200-1
ISBN 978-0-596-52983-3 ()
-, 2013
Authorized Russian translation of the English edition of Learning the vi and Vim
Editors, Seventh Edition ISBN 9780596529833 2008 OReilly Media, Inc. All rights
reserved. This translation is published and sold by permission of OReilly Media, Inc.,
the owner of all rights to publish and sell the same.
,
.
, , .
-.199034,-,16,7,
.(812) 380-5007, www.symbol.ru. N 000054 25.12.98.
12.12.2012. 70100 1/16.
. 32 ..
, .
( )
10
I. vi 19
1. vi 21
24
25
29
2. 32
vi 32
33
37
50
J 52
vi 53
3. 55
55
59
60
64
vi 65
4. 67
67
vi 68
71
73
74
vi 74
5. ex 75
ex 76
ex 78
84
86
87
6. 91
92
, 93
94
102
110
7. 116
vi 117
UNIX 121
124
ex 137
143
8. vi 149
: , 149
151
152
152
154
160
165
: 167
167
168
172
Vim 177
Vim UNIX GNU/Linux 178
Vim Windows 183
Vim Macintosh 183
184
185
185
187
189
196
198
201
203
206
( ) 209
211
213
217
221
222
223
224
236
, Vim 245
250
320
: -ASCII 322
324
326
Vim 328
HTML 329
? 330
332
? 333
? 336
Vim 338
( Vim) 339
340
III. vi 341
343
344
- 345
346
346
348
348
349
352
352
353
354
355
- 356
356
358
360
366
366
371
374
elvis 380
380
382
383
- 384
386
387
389
398
400
407
410
417
IV. 419
495
, vi
. vi
.
,
UNIX, vi
. vi Vim ( vi improved),
(Bram Moolenaar) ,
. Vim
, . ,
, vi,
II Vim.
vi, III vi.
4 18 4 .
I vi
vi, ,
.
1 vi
vi, .
, . 2
.
vi
.
. 3
4
.
, , vi ,
.
.
11
5 ex, 6 7 ,
.
ex, vi,
, vi ex.
8 vi ,
vi.
, ,
, , ,
, .
, vi,
UNIX-
( GNU/Linux).
II Vim Vim
vi.
9 Vim (vi Improved): Vim,
,
Vim.
10 Vim vi
Vim vi,
, ,
.
11 Vim
, , ,
vi.
.
12 Vim Vim,
, Vim
. Vim
,
Vim.
13 Vim (gvim) Vim
, ,
UNIX-, GNU/Linux
UNIX-, MS Windows.
14 Vim
Vim ,
.
-, ,
--.
15 Vim ,
,
.
12
III vi
vi: nvi, elvis vile.
16 nvi: vi, 17 elvis 18 vile: vi Emacs
vi: nvi, elvis vile.
, ,
.
IV .
A vi, ex Vim
vi ex, . ,
ex , vi ex
Vim.
B set
vi .
C
vi , .
D vi ,
vi UNIX .
,
vi. ,
vi, .
.
vi, ,
Vim. nvi,
elvis vile. ,
.
vi
,
.
.
MonoCondensed. ,
. ( , ,
)
MonoCondensed. ,
. , :
13
vi [filename]
filename . ,
vi .
.
,
UNIX. ,
, MonoCondensed Bold,
. :
$ ls
ch01.xml ch02.xml ch03.xml ch04.xml
,
.
, .
UNIX,
printf(3) (
man).
printf() 3 (
man 3 printf, ).
,
vi :
ZZ
ZZ .
( ) ,
.
. , ZZ
,
; .
.
vi
CTRL .
: CTRL-G.
(^),
^G , G
CTRL.
14
, ,
.
,
.
, .
, Learning the Unix Operating System
(OReilly) - UNIX. ,
:
;
UNIX;
;
;
, .
grep (global search program,
) .
, ,
:
OReilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
:
bookquestions@oreilly.com
- ,
. :
http://www.oreilly.com/catalog/9780596529833
,
, ,
OReilly Network -:
http://www.oreilly.com
15
Learning the vi Editor
ex . 5, 6 7
ex vi , ,
, .exrc, ,
.
Unix World. (Walter Zintz) vi
1,
,
. (Ray Swartz)
2.
, .
Learning the vi Editor
,
.
vi. ,
vi. nvi, Vim,
elvis vile .
:
.
.
16
, vi, /
, ,
.
, , ,
, vi.
, vi
UNIX .
Learning the vi and Vim Editors
. , Vim
vi,
( ).
, nvi, elvis vile.
:
.
, Vim.
nvi, elvis vile.
,
ex vi, ,
Vim.
.
vi
:
vi Solaris vi UNIX.
nvi 1.79 (Keith Bostic).
elvis 2.2 (Steve Kirkendall).
Vim 7.1 (Bram Moolenaar).
vile 9.6 (Kevin Buettner), (Tom
Dickey) (Paul Fox).
17
,
,
.
.
(Paul Manno)
(Georgia Tech College of Computing)
.
(Len Muellner) (Erik Ray) OReilly & Associates
SGML. vi, (Jer
ry Peek), .
,
Vim 4.5 5.0 GNU/Linux (Red Hat 4.2).
(Keith Bostic), (Steve
Kirkendall), (Bram Moolenaar), (Paul Fox),
(Tom Dickey) (Kevin Buettner),
8
12 ( ).
, ,
.
, . ,
, . (Gigi Estabrook) OReil
ly . .
, .
, OReilly & Associates.
(Arnold Robbins)
Raanana, , 1998
18
. .
, .. (J.D.Illiad Frazer)
User Friendly1.
, ,
.
.
(Keith Bostic) (Steve
Kirkendall) . (Tom
Dickey) vile
set B. (Bram Moolenaar),
Vim, . .
. (Robert P.J.Day), (Matt Frye), (Judith
Myerson) (Stephen Figgins)
.
(Andy Ora)
(Isabel Kunkle) ,
OReilly Media.
(Arnold Robbins)
, , 2008
(Elbert Hannah)
, , , 2008
I
I.
vi
I vi,
, vi .
vi,
;
vi. I :
1 vi
2
3
4
5 ex
6
7
8 vi
1
1.
vi
UNIX1 ,
, , ,
. , ,
ed ex, .
, , vi Emacs,
. ,
X Window System,
. GNU Emacs, XEmacs
X-;
sam Acme Bell Labs. Vim
, X.
vi
. (vi visual editor,
; -.
.1.1.) Emacs,
UNIX,
-2 .
1
UNIX ,
UNIX, UNIX-
. Sola
ris ( OpenSolaris
. . . .), AIX HP-UX,
GNU/Linux ,
BSD. ,
.
22
1. vi
ed ex,
( ,
).
, , ,
, .
,
, .
!
LINUX, ,
"".
, ,
,
.
,
"".
,
?
,
"VI"?
- ,
"".
""?
http://www.userfriendly.org/
U S E R F R I E N D LY b y I l l i a d
.1.1. vi
vi
,
.
, , vi (command
mode). ,
(insert mode).
, vi .
vi, , .
,
. vi
,
, , .
vi ( )
what you see is what you get ( , ).
,
, ,
. ,
, ,
.
.
,
23
. UNIX
troff1.
TEX LATEX2.
(, vi
. ,
.
, Vim 7 .3)
, ,
.
vi,
.
? -,
(insert) (,
) , , (dele
te) ( ).
(change) (
). , (move)
. ,
(copy) , .
, ,
, vi ,
. (
,
.)
. :
i
(insert).
cw
(change word).
troff
- nroff
. .
UNIX , troff .
, troff, GNU-, groff.
http://www.gnu.org/soft
ware/groff/.
TEXLATEX http://www.ctan.org
http://www.latex-project.org .
Vim ,
. . . .
24
1. vi
,
.
,
.
!
,
.
, vi:
(
: I , i).
, .
ENTER .
,
. . (/)
(?) ; 3.
ex (:);
ex. vi, ex
, vi
. ex 5,
ex .
vi ,
. ,
vi ,
, vi .
vi ,
, .
. (
, ..),
. , UNIX ,
,
, ,
.
( ) stty.
vi,
(University of California, Berkeley, UCB),
(
) (
), termcap ( terminal
capabilities). 80- System V ,
, terminfo
25
( terminal information).
. vi,
,
TERM. ,
.profile .login.
(, xterm). ,
TERM. (, vi
.
.
,
.) ,
vi, Vim . Mic
rosoft Windows Mac OS X , ,
. vi ( -
) ,
TERM termcap terminfo,
stty.
vi, .
vi ,
, UNIX
, .
, vi
,
1. vi
, .
vi
. vi (
), (
, )
, .
vi
, .
, ,
, ,
.
.
, ,
- , .
26
1. vi
vi UNIX, vi
.
:
$ vi [filename]
, , ,
. . $
UNIX. , vi
.
.
.
.
8- ,
(/),
, ASCII NUL
. ;
(\).
, , (.)
(_). , UNIX :
. ENTER,
UNIX , .
, vi
. ,
practice, :
$ vi practice
, ,
:
~
~
~
"practice" [New file]
(~) ,
, . (
) .
,
. ,
/home/john/letter.
/home/john, .
$ vi letter
letter.
27
, ,
:
$ vi /home/john/letter
vi [open mode]
, .
, :q.
$TERM.
.
.
:
Visual needs addressable cursor or upline capability
Bad termcap entry
Termcap entry too long
terminal: Unknown terminal type
Block device required
Not a typewriter
, -
terminfo termcap. :q, .
$TERM
.
[new file], ,
.
,
( UNIX ).
, , . :q
. , ,
( pwd UNIX).
, (
ls) , .
vi, (
,
ex).
, , vi
. vi, ex (:) vi.
:
[Read only]
File is read only
Permission denied
Read only , ;
. , vi
28
1. vi
( view, vi -R)
.
.30.
:
Bad file number
Block special file
Character special file
Directory
Executable
Non-ascii file
file non-ASCII
, ,
. :q! ,
file.
:q
:
No write since last change (:quit! overrides).
. vi
:q!. , ,
.
,
vi. :
. ,
.
, , .
, ,
. , , ,
.
ESC, . ,
vi (beep) ESC. (
.)
,
,
.
,
UNIX. vi,
,
ZZ. , ZZ .
29
, practice
. , ESC
, , ZZ.
ZZ
ls
ch01
ch02
practice
,
practice.
ex.
(write) , vi, :w.
, :q,
:wq, vi. (:wq ZZ.)
5 ex.
.
vi,
, ex,
.
,
:e! ENTER
,
.
vi,
:q! ENTER
UNIX. ,
. vi
. ,
:e :q, vi ,
, .
30
1. vi
File exists
File file exists - use w!
[Existing file]
File is read only
:w! file, , :w
newfile, .
,
. Permission denied.
:w newfile,
.
mv
.
, :w pathname/file, ,
(,
/tmp).
, ,
.
:!rm junkfile, () ,
. ( ex
, UNIX.)
:!df, ,
. ,
, :w pathname. (df
UNIX, ;
disk free.)
(open mode)
, .
vi. :!ls /tmp,
, , ,
1. ,
UNIX, ,
UNIX. ,
:sh; vi CTRL-D
exit. ( UNIX
CTRL-Z, vi
1
vi /usr/tmp, /var/tmp
; , ,
, . Vim
, .
31
UNIX; vi fg.)
:w!.
, ,
.
:pre ( :preserve). ,
. :sh ( CTRL-Z,
),
vi . vi CTRL-D (
fg). :w!.
vi .
,
UNIX. practice, ,
.
practice :
vi practice
ESC
vi :
ZZ
2
2.
, ,
vi. ,
. vi,
.
,
. vi
(
).
vi, .
, ,
.
vi, ,
, , .
vi,
, .
, :
,
vi
vi : .
, .
,
, .
33
(
), UNIX.
.
.
- .
vi .
i. i
, , ,
.
1. ESC.
(
) vi .
, intro
duction. iintroduction, :
introduction
vi
(i) .
,
ESC. ,
BACKSPACE .
BACKSPACE
,
. .
, BACKSPACE
, . ( Vim
vi,
.)
vi ,
.
ENTER.
, .
vi , , ESC
, , . ,
.
,
,
.
1
,
.
34
2.
.
(,
) ,
, , ,
.
vi , :
, , .
, ,
.
.
.2.1
. ,
vi.
O
b
2k
$
With a screen editor you can scroll the
page, move the cursor, delete lines,
and more, while seeing the results of
your edits as you make them.
2h
2w
.2.1.
h, j, k l,
, :
h
.
j
.
k
.
l
.
(, , , ), + ENTER BACKSPACE,
. ,
, ,
vi, ,
.
35
ESC, ,
. h, j, k l,
.
- ,
, . ,
, h l (
) ( ) , j
k1.
(~), ,
.
. 2.2
, 4l
, l (llll).
. ,
.
4l
With a screen editor you can scroll the
.2.2.
practice vi
.
( 80 ).
. (
ENTER
.) ENTER 200 , vi
200 ( ,
).
1, vi ,
,
. wrapmargin (
wm). wrapmargin 10:
:set wm=10
1
Vim nocompatible
l .
36
2.
. 7
,
!
wrapmargin,
,
.
:
0 ( )
.
$
.
. (vi
, number,
:set nu . 7.)
1 With a screen editor you can scroll the page,
2 move the cursor, delete lines, insert characters,
and more, while seeing the results of your edits
as you make them.
3 Screen editors are very popular.
(3) ,
(5). $, d
delete, them. 0
m move 2.
, ,
, .. w
,
.
w:
cursor, delete lines, insert characters,
W
( Word).
W :
cursor, delete lines, insert characters,
b.
B , .
37
,
, b, w .
2w , 5B
.
G. G
, 1G , 42G
42. G (Go To)
.64.
3 ,
.
.
. ,
, .
, ,
. .2.3 ,
.
.
vi
: i ( ), a ( append)
, c ( change) d (delete).
,
. ,
d p (put);
y (yank), p
38
2.
. .
.2.4 vi, .2.3.
i screen ESC
rs
dd
cw
insert
ESC
re
r.
x
rS
.2.4. vi
,
.
,
. , practice
:
you can scroll
the page, move the cursor, delete
lines, and insert characters.
.
With a screen editor, :
2k
iWith a
39
screen editor
ESC
a (append)
. i,
, . , ,
i
, -. , a
.
.
c (change). , ,
.
, c.
, c , :
cw
.
c2b
.
c$
.
c0
.
, ,
. i a, c
ESC.
, vi
$, ,
(. cw ).
40
2.
, c (change) w.
(cw) (
). cw
, ESC.
, practice:
With an editor you can scroll the page,
an screen. :
cw
a screen
cw . , spell
ing spelled, i, cw, ed
, ESC.
,
cc.
, ,
ESC.
cw cc. cw
,
. ESC.
cc, ,
.
,
,
, .
41
vi
,
:
(command)(text object)
:
(number)(command)(text object)
number command .
. ,
. , (c, d y)
, .
,
, vi !
C
. c
(c$).
, cc C ,
, vi.
, .
r.
.
ESC, .
:
Pith a screen editor you can scroll the page,
42
2.
.
cw, .
r, :
rW
, ,
. (s, substitute)
. ,
. c,
$, , .
S, ,
, . C,
, S
. vi
. , ,
.
s S ;
ESC.
R, , .
, R .
ESC.
; ENTER vi ,
.
. (~)
, .
, ,
~. ,
.
vi
.
.
,
UNIX, tr,
7.
43
d
(delete). , d
( ).
(dw), (dd D) ,
.
, :
Screen editors are are very popular,
since they allowed you to make
changes as you read through a file.
. ,
are :
2w
dw
dw , , .
, .
dw . :
since they allowed you to make
ed allowed.
dw
44
2.
dw , .
.
, de.
, .
(db), (d$)
(d0).
dd , ,
. cc, dd .
, ,
, :
Screen editors are very popular,
since they allow you to make
changes as you read through a file.
2dd
D ,
. (D d$.) ,
:
Screen editors are very popular,
since they allow you to make
changes as you read through a file.
45
.
r, , x ,
. :
zYou can move text by deleting text and then
z, x1. X ,
.
, . ,
5x .
,
.
.
u, (
, dd). , ,
u .
U ,
- .
,
p, vi
. , ,
, :
"3p
3 .
.
.
, u ,
p. .
u p.
, Vim ,
. .332
.
vi ,
,
. ,
.
(p),
1
x ,
. ?
46
2.
.
, , .
p ( put)
. (P)
. , p
() .
, ,
.
, practice :
You can move text by deleting it and then,
like a "cut and paste,"
placing the deleted text elsewhere in the file.
each time you delete a text block.
dd
. ,
, .
,
. 4
, .
xp ( )
. , mvoe vo
47
. ,
v x, p.
.
. 129
, .
(
), .
y ( yank ) p ( put )
.
y ,
( ).
.
, y
(yw, y$, 4yy).
( ),
,
.
yy dd cc.
Y D C.
. Y
, yy.
, practice :
With a screen editor you can
scroll the page.
move the cursor.
delete lines.
,
With a screen editor you can.
,
, :
yy
48
2.
2j
jp
,
.
. 4,
.
26 ,
.
. , the
, , ,
.
, ,
(.). ,
, .
49
, :
With a screen editor you can
scroll the page.
With a screen editor you can
move the cursor.
, :
dd
vi .
,
, wrapmargin.
vi, .
, (
, , ).
.
(:w),
. wrapmargin :
:set wm=0
.129
wrap
margin. vi CTRL-@
.
.
,
. u.
, .
,
practice:
50
2.
U, u, ,
, . ,
U.
, u
, . u
U, , ,
, , u.
: , u ,
.
, .
. ,
.
Vim CTRL-R.
,
.
.332.
:
i ESC
a .
:
A
.
I
.
o ( o)
, .
O ( o)
, .
51
s
.
S
.
R
.
.
ESC ,
.
A (append) I (insert)
. ( A $a.
,
,
.)
o O (open) .
, .
s S (substitute)
. s
c SPACE, S , cc.
s .
R (, replace) , ,
, . , ,
: 3cw 4cw, R, .
o O, ( i a)
.
i, I, a A,
. , 50i* ESC
50, 25a*- ESC 50 (25
). , 1.
r, ,
.
, C C++ || &&,
2r&.
, S
. c
, .
vi
.
52
2.
s
. r ,
cw . s
R.
,
. , ea .
.
J
, .
, J.
practice :
With a
screen editor
you can
scroll the page, move the cursor
J
. 3J.
.
, j, J.
, CAPS LOCK. vi
, (I, A, J, ..)
53
vi
vi
2.1 , ,
c, d y .
. .2.2
2.3 , .2.4
, .
2.1.
cw
dw
yw
2cW c2W
2dW d2W
2yW y2W
3cb c3b
3db d3b
3yb y3b
cc
dd
yy Y
c$ C
d$ D
y$
c0
d0
y0
x X
yl yh
5s
5x
5yl
2.2.
, , ,
h, j, k, l
e E
w W
b B
54
2.
2.3.
P p
vi, ,
vi file
ZZ
:q!
2.4.
vi,
. vi (
), .
.
3
3.
vi ,
.
, ,
,
.
(, ex,
). ,
( , ,
). vi
.
.
:
,
,
,
.
, ,
. .
,
. (!) .
.
, ( ) 24 .
56
3.
.
ENTER ,
. (scrolling).
.
,
.
vi,
.
^F
.
^B
.
^D
() .
^U
() .
( ^ CTRL. , ^F ,
CTRL f.)
(^E) (^Y).
.
, .
z
, z.
zENTER
.
z.
.
z .
z .
( ,
. z .)
z ,
. zENTER
57
, 200zENTER
200.
. ,
.
.
(
), ,
. , CTRL-L
.
( ),
:
H
() .
M
.
L
.
nH
n .
nL
n .
H ( home)
. M , L .
, , 2H.
58
3.
2H
,
. j k.
:
ENTER
.
+
.
.
, . j k
,
, ( ,
).
, h l , 0 ()
$ . :
^
.
n|
n- .
, ^
, . 0,
, ,
.
59
vi
, , , .
, (w, W, b B). ,
:
e
.
E
( ).
(
.
)
.
{
.
}
.
[[
.
]]
.
vi
: ?, . !. ,
.
, vi
.
(.IP, .PP, .LP, .QP) MS
troff. (.NH, .SH, .H 1
.HU). , ,
:set, 7.
, .
, 3) .
, : d)
, 2y}
.
60
3.
, , ,
(pattern). ,
.
/ ( ).
. ,
: /.
( ). ,
red, ,
occurred. ,
. ,
, ENTER.
vi, UNIX,
, ,
, , The
.
6.
.
vi ,
.
. ,
Pattern not found ( )1.
practice :
/edits
/scr
vi,
. ,
.
61
. ,
,
.
? /:
?pattern
.
,
:
n
.
N
.
/ENTER
.
?ENTER
.
, ,
- ,
, n, N, / ?
. (/ , ? )
. (nvi
n N. Vim ,
.)
scr ,
:
62
3.
?you
, ,
. vi wrapscan .
, :
:set nowrapscan
nowrapscan ,
:
Address search hit BOTTOM without matching pattern
nowrapscan ,
TOP BOTTOM.
/ ?
, c d. :
d?move
, ,
.
. 6
.
63
,
. fx
x ( x
). tx ,
x.
; ( ).
.
.
fx
x
(x ).
Fx
x
.
tx
x
.
Tx
x
.
;
.
,
.
n n- .
, practice :
With a screen editor you can scroll the
fo
64
3.
dfx x .
dw ,
, . t f,
, . ,
ct.
, .
,
.
. ,
, . ,
ex,
.
, -
. :set nu,
7. vi -
.
CTRL-G ,
. , prac
tice CTRL-G :
"practice" line 3 of 6 --50%--
CTRL-G ,
, , ,
.
vi
,
, .
.
G (Go To)
. G (Go To)
.
, 44G 44. G
.
,
(``) ( G).
65
vi
- ,
, G, ``
. (/ ?),
`` . ('')
, ,
, .
, CTRL-G,
,
. 10- 1000 :
"practice" line 10 of 1000 --1%--
- ,
800G.
.
vi
.3.1 , .
3.1.
^F
^B
^D
^U
^E
^Y
z ENTER
z.
z-
^L
ENTER
66
3.
3.1 ()
n-
n|
( )
[[
]]
/pattern
?pattern
fx
Fx
tx
Tx
nG
``
''
( ^G
)
4
4.
vi: i,
a, c, d y, . :
,
.
vi.
,
.
.
2 c, d y,
(,
2cw 4dd). 3
.
, .4.1
.
, .4.1
:
(number)(command)(text object)
number .
command c, d y, text object
.
vi 2 ( .2.1
2.2).
68
4.
4.1.
...
cH
dH
yH
cL
dL
yL
c+
d+
y+
c5|
d5|
y5|
5-
2c)
2d)
2y)
2-
c{
d{
y{
c/pattern
d/pattern
y/pattern
pattern
cn
dn
yn
pattern
cG
dG
yG
c13G
d13G
y13G
13
vi
vi :
$ vi file
vi . ,
, ,
.
, .
,
, 1:
$ vi +n file
file n.
$ vi + file
file .
$ vi +/pattern file
file pattern.
practice
Screen :
1
POSIX, +command vi
-c command. ,
.
69
vi
vi +/Screen practice
,
. ,
1:
+/"you make"
:
+/you\ make
,
, 6, , ,
, -.
+/pattern ,
.
,
, ZZZ HERE. ,
/ZZZ /HERE
.
, vi wrapscan .
wrapscan (.
.61), +/pattern.
vi
Address search hit BOT
TOM without matching pattern.
,
(,
vi
).
1
, vi.
70
4.
(read-only),
,
. :
$ vi -R file
$ view file
( view, vi,
1.)
,
, :
:w!
:
:wq!
, C.
. ,
(), . -r,
,
.
UNIX vi
, ,
. , :
$ ex -r
:
$ vi -r
, .
-r
. ,
practice , :
$ vi -r practice
,
,
.
:pre ( :preserve)
, .
1
, view vi.
71
, ,
- . (
,
. .
.30.)
vi ,
. vile .
autowrite autosave.
, , vi .117.
, (d
x) (y) 1 (
).
(p P) .
vi .
, -
( ). (
, ,
. p P
.)
vi y
. 26(az)
, ,
p .
,
53 ?
,
. 1, 2 ..
, " ( ),
, p.
, :
"2p
2 .
1
:
()
; , vi
. . . .
72
4.
, ,
"np. (.)
p u .
, :
"1pu.u.u
..
. u
, (.),
. u .,
.
, (
p P) ,
. y d
26 ( a z),
.
, ,
.
,
y (") ,
, . :
"dyy d.
"a7yy a.
p P, :
"dP
"ap
d .
a .
.
. vi,
.
vi,
.
.
:
"a5dd
a.
73
. .
:
"zd)
z.
2)
.
"Zy)
z.
, ,
,
,
, .
vi ,
. :
mx
x (x
). , vi
. Vim
.
'x
(). x.
`x
( ). , x.
``
( ). 1
.
''
(). ,
.
vi
.
(previous mark)
, -
. . . .
74
4.
,
ex,
.
vi
.4.2 vi,
. .4.3 4.4
.
4.2.
+n file
file n.
+ file
file .
+/pattern file
file (POSIX
-c).
-c command file
command file.
,
(POSIX- +).
( ,
view vi).
.
-R
-r
4.3.
19
( ,
).
.
.
az
4.4.
x .
'x
x.
`x
x.
.
``
''
,
.
5
5.
ex
: vi,
? , ex .
vi ,
, ex.
vi .
, vi1.
,
. ex
.
,
, . ,
.
ex . , :
, ;
ex, ,
;
;
( ,
).
vile ,
ex. 18.
76
5. ex
ex
vi
, (
).
, ,
.
.
( )
,
, .
,
ex
, ex.
vi, ex
.
, ,
,
, ,
. ex , , ,
,
. ,
, ,
.
ex (,
, ),
. , ex
,
.
practice
ex.
vi. ex
.
:
$ ex practice
"practice" 6 lines, 320 characters
:
ex ,
.
ex ( )
, ( ENTER).
p ( print) .
ex
77
, 1p,
.
:1p
With a screen editor you can
:
p,
.
, (, 1,3 ,
, ). :
:1,3
With a screen editor you can
scroll the page, move the cursor,
delete lines, insert characters, and more,
. ,
(s), ,
:
:1
With a screen editor you can
:s/screen/line/
With a line editor you can
,
.
:
:1s/screen/line/
With a line editor you can
ex vi
, -
ex . ,
, , .
ex practice, vi
, .
:vi ex vi.
ex vi,
: () .
ENTER, . , ex
. 6
vi, :
:6
ENTER.
ex
vi.
78
5. ex
: ex
UNIX
ex practice:
ex practice
:1
():
() 1 3:
:1,3
1 screen:
:1s/screen/line
vi :
:vi
:1
vi ex.
Q, vi, ex.
, vi vi.
ex
ex
vi. ,
dw dd, delete ex. ex
, .
.
. ,
vi ex .
, ,
, .
delete
move
copy
co
( co)
ex
. , ,
.
.
ex
79
ex
( ), . ex
,
.
:
;
,
;
,
.
.
.
, ,
. :
:3,18d
3 18.
:160,224m23
160 224 23 (
vi).
:23,29co100
23 29 100 (
vi).
,
. :
:set number
:
:set nu
. practice :
1
2
3
4
.
vi set:
80
5. ex
:set nonumber
:set nonu
, #.
, :
:1,10#
1 10.
3, CTRL-G
. ,
, CTRL-G,
CTRL-G , ,
.
ex =:
:=
.
:.=
.
:/pattern/=
, pat
tern.
. (.)
, $
, % .
1,$.
.
,
:.,$d
.
:20,.m$
, 20-
.
:%d
.
:%t$
(
).
ex
81
. + -
. ,
. :
:.,.+20d
20 .
:226,$m.-2
226- ,
.
:.,+20#
20 .
+ - (.) ,
.
+ - , +1
-1 1. ++ --
, .. ,
+ - .
0 ( )
1-.
, ,
. :
:-,+t0
(
) .
ex .
:
:/pattern/d
, pattern.
:/pattern/+d
, , pattern.
( + +1.)
:/pattern1/,/pattern2/d
, pattern1, ,
pattern2.
1
. , +10 10
, + 10 11 (1+10), ,
.
82
5. ex
:.,/pattern/m23
(.) , pattern,
23.
,
.
vi, ex,
, 1.
practice :
With a screen editor you can scroll the
page, move the cursor, delete lines, insert
characters and more, while seeing results
of your edits as you make them.
d/while
:.,/while/d
. ,
1 100
. :
:100,+5 p
- ,
100 , , .
1
ex , ,
vi . . . .
ex
83
ex .
, .
, :
:100;+5 p
. +5
100.
, . , ,
pattern, 10 , :
:/pattern/;+10 p
, vi / ( )
. ex g ( global),
.
:g! : ( :v)
, .
,
.
:g/pattern
( ) pattern .
:g/pattern/p
, pattern.
:g!/pattern/nu
( ),
pattern.
:60,124g/pattern/p
,
60 124, pattern.
, g
. 6.
ex
ex,
. (|)
ex,
ex ( ,
UNIX).
| .
,
. :
84
5. ex
:1,3d | s/thier/their/
1- 3- (
), (
4 ex).
:1,5 m 10 | g/pattern/nu
1- 5- 10,
(), pattern.
, ,
.
vi ZZ,
() .
ex,
.
. :
:w
() , .
() :w
,
.
:q
(
UNIX).
:wq
: .
, .
:x
.
, 1.
vi , .
,
vi . , vi
, ,
:
No write since last change.
( )
:wq :x
make, .
85
,
.
(!) :
:w!
:q!
:w! ,
vi -R view (,
).
:q! ,
,
, .
.
:w
( ) .
practice, 600 . ,
, ,
practice, ,
.
practice.new, :
:w practice.new
, practice,
( :w). :q
.
. ,
,
.
w. ,
practice newfile,
:
:230,$w newfile
230- newfile.
:.,600w newfile
600- newfile.
86
5. ex
w
UNIX (>>).
. , :
:1,10w newfile
:340,$w >>newfile
. vi
ex:
:read filename
:
:r filename
filename,
. ,
, , (
) read r.
, practice
data , /home/tim.
,
, :
:r /home/tim/data
/home/tim/data practice,
.
185, :
:185r /home/tim/data
:
:$r /home/tim/data
.
:0r /home/tim/data
.
:/pattern/r /home/tim/data
,
pattern.
87
ex .
.
vi
.
,
.
(. 7),
(yank) .
vi
vi
, ex
. :
$ vi file1 file2
file1.
ex :w () file1,
:n (file2).
: practice note.
vi practice note
:w
:n
Dear Mr.
Henshaw:
Thank you for the prompt . . .
ex :n note,
ENTER .
:x
88
5. ex
ex ,
:n. :args (
:ar) ,
, .
vi practice note
:args
[practice] note
vi (
).
:rewind (:rew) ,
. elvis Vim
:last, .
. :e
. vi ,
(:w), :
:e filename
, practice
letter, practice:
:w
:e letter
89
vi .
% ( ) # (
). # :e,
.
:e #
(practice). practice
, :r #.
, vi
:e :n,
,
.
, letter
practice, :e! #.
.
:
:e!
#, %
. ,
.85 ,
practice :
:w practice.new
%,
:
:w %.new
vi
, ,
,
ex. vi ^^ ( Ctrl ) .
:e #. :e,
, vi .
(yank) ,
.
vi :e
. ,
(
), :e
,
.
90
5. ex
,
.
"f4yy
:w
:e letter
Dear Mr.
Henshaw:
I thought that you would
be interested to know that:
Yours truly,
letter :e ,
.
"fp
Dear Mr.
Henshaw:
I thought that you would
be interested to know that:
With a screen editor you can scroll
the page, move the cursor, delete lines,
insert characters, and more, while seeing
the results of the edits as you make them
Yours truly,
f
.
ex :ya ( yank) :pu ( put).
, vi- y p,
, ex.
, :
:160,224ya a
160- 224- a. :e
, ,
, ,
:
:pu a
a .
6
6.
. ,
,
( !). ,
.
.
,
( ) .
ex
. ,
, ex .
, ,
.
ex : :g (global)
:s (substitute).
, .
:
:s/old/new/
old
new. / ( )
( ,
).
:
:s/old/new/g
92
6.
old new. :s
. g
. ( g
; :g,
.)
:s ,
. ,
old new 50- 100-:
:50,100s/old/new/g
old new :
:1,$s/old/new/g
, 1,$
%. ,
:
:%s/old/new/g
.
,
,
- .
, , .
, u
. ,
.
:w .
. :e!,
.
,
.
,
c (confirm):
:1,30s/his/the/gc
ex
(^^^^):
copyists at his school
^^^
93
, y (yes) ENTER.
ENTER.
this can be used for invitations, signs, and menus.
^^^
vi n ( ) (.) (
)
,
. ,
which that,
which :
/which
which
cwthat ESC
n
n
.
that
,
( )
(..)
,
( )
. (editer
editor), :
:%s/editer/editor/g
editer editor .
, .
,
. ,
.
:
:g/pattern/s/old/new/g
g . pat
tern , , ,
pattern, ex (s) (old)
(new). g ,
.
, XML-
<keycap> </keycap> ESC,
Escape. , ESC
, Escape, .
Esc ESC <keycap>,
:
94
6.
:g/<keycap>/s/Esc/ESC/g
, ,
. , :
:g/string/s//new/g
, string,
string.
, :
:g/editer/s//editor/g
, :
:%s/editer/editor/g
.
:g :s, ex,
:d, :mo :co.
, .
UNIX-, vi,
,
,
.
-,
. ,
- .
. ,
vi / ?,
ex :g :s.
UNIX, grep, sed, awk1.
2.
.
1
, OReilly: sed & awk (Dale Dougherty)
(Arnold Robbins) Mastering Regular Expressions,
.. (Jeffrey E.F.Friedl)
, 3- . -, 2008.
,
, , ,
, .
UNIX,
.
95
,
. ()
,
. ,
. , p.p ,
pep, pip pcp.
*
( )
, . ,
bugs* bugs ( s), bug ( s), bugss, bugsss ..
* . ,
. () , .*
.
: :s/End.*/End/
End ( ).
^
,
. , ^Part Part,
, ^... . ^
,
.
$
,
. , here:$ here:,
. $
, .
\
,
. , \.
, ; \* ,
. \ ( )
.
(escaping the character).
\\.
[ ]
,
. [AB] A B, p[aeiou]t
pat, pet, pit, pot put.
,
. , [A-Z]
, [0-9] 0 9.
96
6.
,
. , [:;A-Za-z( )]
.
vi
, ASCII.
,
, a z.
,
POSIX (
) a-z.
,
. ,
\, - ]. (-)
,
, .
(^) ,
,
^.
, ^ ,
. , [^0-9]
.
\( \)
, \( \),
(hold buffer).
. , :
\(That\) or \(this\)
That 1, this
2.
\1 \9. , That or
this this or That, :
:%s/\(That\) or \(this\)/\2 or \1/
\n. :
:s/\(abcd\)\1/alphabet-soup/
abcdabcd alphabet-soup1.
\< \>
(\<) (\>) .
,
1
97
. , \<ac
, ac, action. ,
ac\> , ac, ma
niac, react .
, , \(...\), .
~
,
. , The, Then
/~n.
( /)1.
,
.
()
.
.152.
POSIX
, [a-z]. POSIX
. , ,
[a-z] .
,
() .
, POSIX . ,
(bracket
expression). ,
(a, ! ), :
POSIX ,
[: :]. ,
, .. (. .6.1).
,
. ,
[. .].
vi.
,
~, , .
, .
, .
98
6.
,
, e .
, [= =].
. , [[:alpha:]!]
, [[.ch.]]
ch, c h. [[=e=]]
e, . .6.1.
6.1. POSIX
[:alnum:]
[:alpha:]
[:blank:]
[:cntrl:]
[:digit:]
[:graph:]
(-)
[:lower:]
[:print:]
( )
[:punct:]
[:space:]
[:upper:]
[:xdigit:]
HP-UX 9.x ( ) vi
POSIX. /usr/xpg4/bin/vi ( /usr/bin/vi) So
laris. nvi, elvis, Vim vile.
, GNU/Linux ,
,
,
POSIX.
,
( )
.
, :
:%s/1\. Start/2. Next, start with $100/
99
, . $
, . ,
, :
:%s/[ABC]/[abc]/g
A a, B b C c,
.
, A, B
C [abc].
-
. ,
, .
\n
, n- ,
\( \), n 1 9,
( )
( \( \)
,
.95).
\
,
.
, .
, (\\).
&
, & ,
. ,
:
:%s/Yazstremski/&, Carl/
, &
.
~
, ,
: ,
. .
, :s/thier/their/,
:s/thier/~/.
.
100
6.
, :s/his/their/,
:s/her/~/1.
\u \l
,
(uppercase) (lowercase) .
, yes, doctor Yes, Doctor, :
:%s/yes, doctor/\uyes, \udoctor/
,
.
, \u \l
. , , :
:%s/\(That\) or \(this\)/\2 or \1/
this or That.
. \u,
this (
2), \l,
That ( 1):
:s/\(That\) or \(this\)/\u\2 or \l\1/
This or that (
l, ; ).
\U \L \e \E
\U \L \u \l,
,
\e \E. \e \E , \U \L
. , Fortran ,
:
:%s/Fortran/\UFortran/
&, :
:%s/Fortran/\U&/
. the
The. ,
, :
/[Tt]he
:set ic vi .
7 .
ed
% .
101
:
:s :s//~/. ,
.
,
, .
& (
);
. & g,
,
:
:%&g
& vi.
:& ( ).
, :s ENTER
.
:~ :&, .
, ,
:
.
1, :
:s/red/blue/
:/green
:~
:~ :s/green/blue/.
/ -
,
(\), (") (|).
, :
:%s;/user1/tim;/home/tim;g
edcompatible vi (g
, c ),
, .
,
. :
:s/old/new/g
:set edcompatible
.
, ed UNIX
.
1
102
6.
, ,
,
. .
(). .
. ,
child children.
:w :
:%s/child/children/g
childrenish.
childish.
:e!, :
:%s/child/children/g
( child .)
child., child,, child: .. , ,
,
:
:%s/child[,.;:!?]/children[,.;:!?]/g
child,
( ), : ,.;:!?.
, children,
,
children.
\( \).
\1.
:
:%s/child\([,.;:!?]\)/children\1/g
, \( \), \1
.
, .
, ,
!
. ,
Fairchild ,
child, .
, vi ( ,
) ,
. \<
, , \> ,
. , \<child\>
103
child, ,
. :
:%s/\<child\>/children/g
, mgi, mgr mga:
mgibox routine,
mgrbox routine,
mgabox routine,
,
box square,
. , \(
\) ,
, :
:g/mg\([ira]\)box/s//mg\1square/g
mgisquare routine,
mgrsquare routine,
mgasquare routine,
, (i, r a)
. box square , box
.
:g/mg[ira]box/s/box/square/g
mgisquare routine,
mgrsquare routine,
mgasquare routine,
, ,
, box
, , .
,
. , 150-
, troff.
SYNTAX, DESCRIPTION PARAMETERS.
:
.Rh 0 "Get status of named file" "STAT"
.Rh "SYNTAX"
104
6.
.nf
integer*4 stat, retval
integer*4 status(11)
character*123 filename
...
retval = stat (filename, status)
.fi
.Rh "DESCRIPTION"
Writes the fields of a system data structure into the
status array.
These fields contain (among other
things) information about the file's location, access
privileges, owner, and time of last modification.
.Rh "PARAMETERS"
.IP "\fBfilename\fR" 15n
A character string variable or constant containing
the UNIX pathname for the file whose status you want
to retrieve.
You can give the ...
, DESCRIPTION SYN
TAX. , 150
!
:g /SYNTAX/.,/DESCRIPTION/-1 move /PARAMETERS/-1
: ex
, (
SYNTAX);
(.), .
move , ,
( ) ,
DESCRIPTION (/DESCRIPTION/-1), , ,
PARAMETERS (/PARAMETERS/-1).
, ex
. ex , (-1).
( :
,
, ).
ex. , DESCRIPTION
, :
:g/DESCRIPTION/,/PARAMETERS/-1d
ex, .
,
,
105
, , .
,
. :
1. troff ENTER:
:%s/ENTER/\\fI&\\fP/g
,
,
(\fI
fI. \fI, \\fI).
2. :
:%s/\/home\/tim/\/home\/linda/g
, (
)
, .
/, \/.
. ,
, . (-
ex .)
, :
:%s:/home/tim:/home/linda:g
.
3. HTML- ENTER.
:%s:ENTER:<I>&</I>:g
, &
, , .
4. 1- 10- :
:1,10s/\./;/g
,
(\.).
5. help ( Help) HELP:
:%s/[Hh]elp/HELP/g
:%s/[Hh]elp/\U&/g
106
6.
\U .
, help Help.
6. :
:%s/*//g
,
. , (
, , .
[[:lower:]]), ( )
. ,
(
), 1.
7. ,
, :
:%s/:*/:/g
8. ,
, :
:%s/\([:.]\)*/\1/g
, ,
.
\( \)
\1. ,
( )
.
9. :
:%s/^Note[:s]*/Notes:/g
: ,
s. , Note[s:]
Note, Notes Note:. ,
Note ( ) Notes: (
). Note ,
Notes: Notes::.
10. :
:g/^$/d
(^), ($),
.
11. , ,
:
:g/^[tab]*$/d
1
( vi)
, \+. . . .
107
( tab.)
, .
. , ,
,
. , ,
. ,
( ), ,
:
:g/^[tab][tab]*$/d
12. :
:%s/^*\(.*\)/\1/
^*
, \(.*\)
, \1
.
13. :
:%s/\(.*\)*$/\1/
\(.*\)
, .
.
, g
.
14. >:
:%s/^/>/
>. ,
( ,
) !
Use
net.
.
,
. , (
, .
, ).
.
vi,
.
15. :
:.,+5s/$/./
108
6.
. $
. , $
. .
16. , .
:%s/\(.*\)-\(.*\)/\2-\1/
\(.*\)
-.
\(.*\) .
.
:
more - display files
:
display files - more
lp - print files
:
print files - lp
17. :
:%s/.*/\U&/
:%s/./\U&/g
\U vi
. & ,
, .
, ,
(.*
),
(.
, - g).
18. 1:
:g/.*/mo0
(
, ).
( 0),
. ,
. ,
:
:g/^/mo0
1
109
19. , Paid in
full, Overdue:
:g!/Paid in full/s/$/ Overdue/
:
:v/Paid in full/s/$/ Overdue/
,
, g ! v.
20. , ,
:
:g!/^[[:digit:]]/m$
:g/^[^[:digit:]]/m$
,
, .
: , ,
, .
21. , (,
1.1, 1.2 ..), troff (, .Ah A):
:%s/^[1-9]\.[1-9]/.Ah/
,
, .
, (
\ ).
, . ,
:
:%s/^[1-9][0-9]*\.[1-9]/.Ah/
:
Introduction
New Functions
:
:%s/^[1-9][0-9]*\.[1-9][0-9.]*//
110
6.
,
. ,
, , , ,
:
[1-9][0-9]*\.[1-9]
:
[0-9.]*
, FORmula TRANslation
,
: \(For\) \(tran\).
, :
\U\1\2. \E,
.
,
. For,
: \U\1.
: \Emula. ,
. tran,
,
, : U\2\Eslation).
,
.
, .
:
the best of times; the worst of times: moving
The coolest of times; the worst of times: moving
moving,
, .
, moving, :
The greatest of times; the worst of times: moving
,
, .
111
:g/moving$/ ,
moving. ,
,
.*. , -
. :
:g/moving$/s/.*of/Thegreatestof/
,
of.
, .
:
The greatest of times: moving
- .
of . : ,
. , of
, :
the best of times; the worst of
the best of
:
:g/moving$/s/.*of times;/The greatest of times;/
.* , of times;.
, .
, .*
. ,
(
). .
, /
() . :
Name: Feld, Ray; Areas: PC, UNIX; Phone: 123-4567
Name: Joy, Susan S.; Areas: Graphics; Phone: 999-3333
,
. ,
Feld, Ray Ray Feld. ,
, .
, :
112
6.
:%s/: \(.*\), \(.*\);/: \2 \1;/
Name: Feld, Ray; Areas: PC, UNIX; Phone: 123-4567
Name: UNIX Feld, Ray; Areas: PC; Phone: 123-4567
,
. ,
. -
.
:
:%s/: \(....\), \(.*\);/: \2 \1;/
Name: Feld, Ray; Areas: PC, UNIX; Phone: 123-4567
Name: Ray; Areas: PC, UNIX Feld; Phone: 123-4567
, ,
. :
:%s/: \(....\), \(...\);/: \2 \1;/
Name: Feld, Ray; Areas: PC, UNIX; Phone: 123-4567
Name: Ray Feld; Areas: PC, UNIX; Phone: 123-4567
, ,
, (
). ,
?
:%s/: \(.*\), \(.*\); Area/: \2 \1; Area/
Name: Feld, Ray; Areas: PC, UNIX; Phone: 123-4567
Name: Ray Feld; Areas: PC, UNIX; Phone: 123-4567
,
. , Area
. .
, :
,
( ),
.
, .
.
,
, :
[[:upper:]][[:lower:]]*
(,
McFly),
:
[[:upper:]][[:alpha:]]*
113
(
, - McGeorge Bundy),
:
:%s/: \([[:upper:]][[:alpha:]]*\), \([[:upper:]][[:alpha:]]*\);/: \2 \1;/
, ?
/ Joy Susan S.
,
. . -
, , .
,
, :
[^,]*
.
, :
[^;]*
, :
:%s/: \([^,]*\), \([^;]*\);/: \2 \1;/
.
Name, :
:g/^Name/s/: \([^,]*\), \([^;]*\);/: \2 \1;/
,
( ):
:g/^Name/s/: *\([^,]*\), \([^;]*\);/: \2 \1;/
:g
, :g ,
, g
. , g ,
, :
:g/mg[ira]box/s/box/square/g
:g/^$/d
UNIX World1
(Walter Zintz) .
, ,
.
1
114
6.
,
ex . ,
10 12- 17- .
:
:1,10g/^/ 12,17t$
g, ! g
1, t,
2 .
10, ex 10 .
g,
, (Zintz). ,
, . 2
,
, :
301
302
303
304
305
306
Part 2
Capability Reference
.LP
Chapter 7
Introduction to the Capabilities
This and the next three chapters ...
400
401
402
403
404
405
555
556
557
558
821
822
823
824
825
.LP
Part 3:
Advanced Features
.LP
Chapter 10
, .
( ) .
begin.
:
:g /^Chapter/ .+2w >> begin
115
.
, Chapter ,
(
Chapter). , Chapter,
, .+2 .
+2 ++ .
begin,
w >>.
, ,
2. , g.
:
:/^Part 2/,/^Part 3/g /^Chapter/ .+2w >> begin
g , Chapter,
, Part2 Part3.
,
begin :
This and the next three chapters ...
Before you can do anything useful
This chapter discusses ...
7, 8 9.
, .
:
:/^Part 2/,/^Part 3/g /^Chapter/ .+2w >> begin | +t$
,
.
( 2), Chapter,
. ,
,
+ (, , +1 .+1).
t$, .
, ,
.
. , ! (
, ,
, .)
7
7.
vi ex.
.
.
. ,
set .exrc
.
, UNIX
vi UNIX.
, ,
(
(mapping) ). ,
@-,
.
ex
UNIX .
.
vi,
.
(,
).
C.
vi
117
vi
vi -.
UNIX
terminfo ( vi
termcap)1.
vi ,
. ,
, vi
, ENTER.
vi ex- :set.
, vi .exrc,
, .
:set ,
.
.exrc ,
. ,
,
.
.exrc , .
, vi ,
EXINIT. EXINIT
, , .exrc.
:set
:set : ,
on () off (),
(,
).
- on
off. :
:set option
:
:set nooption
,
, :
:set ic
.
man terminfo man termcap,
, .
118
7.
vi ,
:
:set noic
.
, window ,
.
(=):
:set window=20
vi ,
. :
:set all
, ,
.
:1
autoindent
autoprint
noautowrite
beautify
directory=/var/tmp
noedcompatible
errorbells
noexrc
flash
hardtabs=8
noignorecase
nolisp
nolist
magic
nomesg
nomodelines
nonumber
nonovice
nooptimize
paragraphs=IPLPPPQPP LIpplpipnpbp
prompt
noreadonly
redraw
remap
report=5
scroll=11
sections=NHSHH HUuhsh+c
shell=/bin/ksh
shiftwidth=8
showmatch
noshowmode
noslowopen
tabstop=8
taglength=0
tags=tags /usr/lib/tags
tagstack
term=vt102
noterse
timeout
ttytype=vt102
warn
window=23
wrapscan
wrapmargin=0
nowriteany
:
:set option?
, :
:set
,
.exrc, .
1
vi
119
, :
number sect=AhBhChDh window=20 wrapmargin=10
.exrc
.exrc, vi,
( ).
, .
, vi.
set, ab map,
vi ex ( ab map ).
.exrc:
set nowrapscan wrapmargin=7
set sections=SeAhBhChDh nomesg
map q :w^M:n^M
map v dwElp
ab ORA O'Reilly Media, Inc.
ex
(vi), .exrc
.
.exrc,
, vi
.exrc . ,
.
vi .exrc
exrc .exrc
:
set exrc
.exrc ,
1.
, ,
, :
set number autoindent sw=4 terse
set tags=/usr/lib/tags
, , :
set wrapmargin=15 ignorecase
1
vi
. exrc .
120
7.
, .exrc
,
.
vi,
, .exrc,
:so (so source).
:
:so .progoptions
.exrc
(
). , ,
.exrc .
:set all, vi
.
, ,
, (, noredraw window ssh). .B.1
Solaris vi .458
.
. - ,
( ) ,
. .
.35 ,
wrapmargin
, .
, (
).
7 15:
:set wrapmargin=10
vi .
(foo
Foo), (
,
) .
noignorecase, wrapscan magic .
,
, ignorecase, nowrapscan nomagic.
autoindent, showmatch, tab
stop, shiftwidth, number list, .
, autowrite.
, vi
UNIX
121
:n (next),
, :!.
UNIX
vi
UNIX. (!)
ex
UNIX:
:!command
, vi, :
:!date
. ENTER
, .
UNIX ,
vi ,
ex:
:sh
CTRL-D.
UNIX :read,
UNIX . :
:r !date
.
:r ,
(
).
,
phone .
phone :
Willing, Sue 333-4444
Walsh, Linda 555-6666
Quercia, Valerie 777-8888
Dougherty, Nancy 999-0000
:
:r !sort phone
sort:
Dougherty, Nancy 999-0000
Quercia, Valerie 777-8888
Walsh, Linda 555-6666
Willing, Sue 333-4444
122
7.
,
, .
: vi, ls,
, .
:
:!ls
file1
newfile
file2
practice
letter
. ENTER .
:r newfile
UNIX
UNIX.
. ex, vi.
, ex
, vi (
).
ex
, ex. ,
phone, 96- 99-.
,
UNIX.
, :
:96,99!sort
vi
vi UNIX,
, vi,
, UNIX.
:
!)command
command .
UNIX
123
vi :
.
, ,
, ,
, .
,
,
(G, { }, ( ), [[ ]], +, -).
,
(, !10+, 10!+
10 ). , w, ,
. (/),
ENTER.
.
. ,
, ,
, 1.
,
,
:
!!command
,
, .
, 96- 99-,
, 96 :
4!!sort
!4!sort
: , ,
.
tr.
:
One sentence before.
With a screen editor you can scroll the page
move the cursor, delete lines, insert characters,
and more, while seeing the results of your edits
as you make them.
One sentence after.
, . , Vim
.
124
7.
!)
tr '[:lower:]' '[:upper:]'
, :
! object !
nroff,
(
fmt). ,
. , , ,
,
.
. vi ex
, .
( ),
, .
,
vi .
ex:
:ab abbr phrase
125
abbr phrase.
, ,
, ;
abbr , .
practice ,
,
. :
:ab imrc International Materials Research Center
ithe imrc
-
(, ), ,
ESC ( ).
,
. ,
:
:unab abbr
:
:ab
, ,
, . , :
:ab PG This movie is rated PG
No tail recursion,
. ,
, .
:
:ab PG the PG rating system
, ,
. ,
UNIX System V,
. 1990 Berkeley
,
the the the the the ...
, ,
vi .
126
7.
vi:
Solaris vi
,
, .
nvi 1.79
, , nvi
.
elvis, Vim vile
.
vi nvi UNIX,
.
map
. ,
, map
.
ab, ,
vi,
.
:map x sequence
x
.
:unmap x
, x.
:map
,
.
,
, ,
:
:
g, K, q, V v
:
^A, ^K, ^O, ^W ^X
:
_, *, \, =
127
= vi
Lisp, .
vi _
^, elvis Vim ,
v, V ^V. ,
.
.
. ,
. vi
:
you can the scroll page
v
.
ex
,
ENTER, ESC, BACKSPACE DELETE
, ex
.
, ,
CTRL-V. ^V ^.
^V .
, ^M, ESC ^[, BACKSPACE
^H ..
,
, ,
,
CTRL. , ^A
:
:map CTRL-A sequence
,
^V: ^T,^W ^X.
^T :
:map CTRL-VCTRL-T sequence
128
7.
CTRL-V ex,
map. ,
. , :
:ab 123 one^Mtwo^Mthree
:
one
two
three
As you recall...
, Section. & ,
.
,
ex, CTRL-V. ,
(|)
ex.
.
, CTRL-V
ex,
.
, :
map - an ex command which allows you to associate
a complex command sequence with a single key.
troff,
:
.IP "map" 10n
An ex command...
, .
. :
1. MS .
(I.IP ").
2. ESC, .
3. (e) ,
(a" 10n).
129
4. ENTER .
5. ESC, .
6. (3x),
(~).
,
.
:map ,
:
:map g I.IP "^[ea" 10n^M^[3x~
, ESC, ENTER
CTRL-V. ^[ CTRLV ESC. CTRL-V ENTER,
^M.
g .
, ,
, . (
), .
,
.
, .
u .
, :
1. :
:map e ea
.
.
, e vi.
,
, .
, E e.
2. :
:map K dwElp
,
E (,
, , e ea). ,
. , - l (
130
7.
) ,
,
.
:
:map K dwwP
w W.
3. :
:map q :w^M:n^M
, ex,
, ex .
,
vi. q ,
quit.
4. troff :
:map v i\fB^[e\fP^[
, .
,
. ,
.
ESC
. ,
troff, .
,
ea , e.
,
(
vi remap,
).
5. HTML- ,
:
:map V lbi<B>^[e</B>^[
: ,
HTML, troff, lb
.
, b
. ,
b .
, b l.
, b B e Ea. ,
l ,
( , ).
131
6. 1 :
:map = xf)xn
, /(
, ENTER.
, map
: x,
f), x
n.
(,
), ,
n .
, , .
7. C/C++:
:map g I/* ^[A */^[
/* ,
*/. ,
:
:map g :s;.*;/* & */;^M
.* ,
( &)
. ,
, /
.
8. :
:map ^J :set wm=0^M.:set wm=10^M
2, vi ,
wrapmargin. map .
wrapmargin ( ),
, .
,
vi ex.
, , ^J vi
( ), , j.
,
, . -
vi,
, .
1
132
7.
, .
,
. ,
map ,
.
, ,
.
, (
..). :
:map! + ^[bi<I>^[ea</I>
+ HTML- .
.
(^[), ,
(bi<I>), (^[)
(ea</I>).
, .
: ,
.
1:
:map! % ^[kA:^[jA
, % ,
. ,
(^[kA:),
,
(^[jA).
,
(% +).
, .
, :
:unmap! x
x ,
( vi x ,
,
).
,
1
133
.
.
1 (
).
(setup)
. ,
,
. ,
, .
ex :
:map #1 commands
1 ( ,
terminfo
termcap, , ,
Escape-
).
,
, map!
:
, . , HTML
:
:map #1 i<I>^[
:map! #1 <I>
,
, <I>
.
, HTML- .
^M ( ),
CTRL-M. , 1
,
k1:
k1=^A@^M
, :
^A@^M
.
1
PC
F1F12. . . .
134
7.
,
od (octal dump) -c ( ).
ENTER,
CTRL-D, od . :
$ od -c
^[[[A
^D
0000000 033 [ [ A \n
0000005
Escape,
A.
,
vi, HOME, END, PAGE UP PAGE DOWN.
terminfo termcap , vi
. ,
map, vi.
Escape- Escape,
.
Escape ex, ^V
. , HOME
IBM PC
vi, 1:
:map CTRL-V HOME 1G
:
:map ^[[H 1G
:
:map CTRL-V END G
:map CTRL-V PAGE UP ^F
:map CTRL-V PAGE DOWN ^B
:map ^[[Y G
:map ^[[V ^F
:map ^[[U ^B
, .exrc.
,
(
), ^V Esca
pe-, .
^V, ,
Escape- (,
) , ^V ,
Escape- .
1
:map ^[[H ^,
, . . . .
135
(,
PC xterm), , ,
, . Vim
:
:map <Home> 1G
.
.
, XML HTML.
(Jerry Peek), OReilly
Learning the Unix Operating System,
:map, XML. (,
, .
ex .142.)
" ADR: need this
:set noremap
" bold:
map! =b </emphasis>^[F<i<emphasis role="bold">
map =B i<emphasis role="bold">^[
map =b a</emphasis>^[
" Move to end of next tag:
map! =e ^[f>a
map =e f>
" footnote (tacks opening tag directly after cursor in text-input mode):
map! =f <footnote>^M<para>^M</para>^M</footnote>^[kO
" Italics ("emphasis"):
map! =i </emphasis>^[F<i<emphasis>
map =I i<emphasis>^[
map =i a</emphasis>^[
" paragraphs:
map! =p ^[jo<para>^M</para>^[O
map =P O<para>^[
map =p o</para>^[
" less-than:
map! *l <
...
,
=f. vi
:
All the world's a stage.<footnote>
<para>
</para>
</footnote>
136
7.
,
.
@-
,
.
( vi
ex, ),
,
@. , :
cwgadfly CTRL-V ESC
:
cwgadfly^[
ESC
g, "gdd.
@g gadfly.
@ vi, (.)
, ex.
@@ @, u U
@.
. @- ,
.
,
. @-
, 6.
ex
ex , .
ex,
, @
. , :
ORA publishes great books.
ORA is my favorite publisher.
1,$s/ORA/O'Reilly Media/g
, g
"gdd, (kk)
(:@g
ENTER). :
ex
137
vi * ex
, @. , @ * *,
() .
ex
ex, , ,
vi.
.exrc, .
, , .
, .exrc,
vi, ex,
.
.
ex
. , UNIX-
spell , :
$ spell sect1 sect2
chmod
ditroff
myfile
thier
writeable
,
, .
.
, ,
.
,
, ,
.
, ex
:
%s/thier/their/g
%s/writeable/writable/g
wq
exscript.
vi :
:so exscript
138
7.
sect1 sect2 :
$ ex -s sect1 < exscript
$ ex -s sect2 < exscript
, , ,
, . ex
, ,
for.
. (, for
. ,
.)
for :
for variable in list
do
command(s)
done
:
for file in $*
do
ex - $file < exscript
done
( ;
.)
correct chmod (
chmod ,
UNIX, Learning the UNIX Operating System,
OReilly). :
$ correct sect1 sect2
ex .
.
139
ex
,
move. :
$ ls
ch01 ch02 ch03 move
$ move ch??
$ ls
ch01.x ch02.x ch03.x move
(ch...)
, - ,
:
for nn in $*
do
mv ch$nn sect$nn
done
,
:
$ ls
ch01 ch02 ch03 move
$ move 01 02 03
$ ls
sect01 sect02 sect03 move
for $* ( )
. . :
for variable in a b c d
variable a, b, c d .
.
:
for variable in `grep -l "Alcuin" *`
variable , grep
Alcuin. (grep -l ,
, , .)
:
for variable
140
7.
variable
, . ,
:
for variable in $*
:
for variable in "$@"
. $*
$1, $2, $3 ..,
"$@" "$1", "$2", "$3" ..
1.
:
for file in $*
do
ex - $file < exscript
done
ex
.
.
heredoc
<<
. (
heredoc.)
correct
:
for file in $*
do
ex - $file << end-of-script
g/thier/s//their/g
g/writeable/s//writable/g
wq
end-of-script
done
- end-of-script .
, ,
,
heredoc. .
heredoc EOF
E_O_F, .
1
ex
141
.
, heredoc
.
. ,
,
exscript. correct
. (
) .
: ex
,
, troff-.
.IP. ,
.KS/.KE (
,
). :
.KS
.IP "TTY_ARGV" 2n
The command, specified as an argument vector,
that the TTY subwindow executes.
.KE
.KS
.IP "ICON_IMAGE" 2n
Sets or gets the remote image for icon's image.
.KE
.KS
.IP "XV_LABEL" 2n
Specifies a frame's header or an icon's label.
.KE
.KS
.IP "SERVER_SYNC" 2n
Synchronizes with the server once.
Does not set synchronous mode.
.KE
UNIX- sort,
.
.
,
. ,
, .
ex:
g/^\.KS/,/^\.KE/j
%!sort
142
7.
.KS .KE.
ex j ( vi J),
.
, -
:
.KS
.KS
.KS
.KS
.IP
.IP
.IP
.IP
. ,
( []
). - ,
. , ex :
,
. ex :
g/^\.KS/,/^\.KE/-1s/$/@@/
g/^\.KS/,/^\.KE/j
%!sort
%s/@@ /^M/g
:
.KS@@
.KS@@
.KS@@
.KS@@
.IP
.IP
.IP
.IP
@@.
j,
.
@@. ( .KE) ,
-1,
.
, ( ) .
.
ex
,
. , ,
, (
) . ex ,
, ,
.
.
, . (
143
, .
.)
, vi - . ,
ex-
:
" Mark lines between each KS/KE block
global /^\.KS/,/^\.KE/-1 s /$/@@/
" Now join the blocks into one line
global /^\.KS/,/^\.KE/ join
" Sort each block--now really one line each
%!sort
" Restore the joined lines to original blocks
% s /@@ /^M/g
, substitute ex ,
.
ex
, , UNIX
ex,
sed awk.
Perl.
, OReilly: sed & awk,
Effective awk Programming, Learning Perl1 Programming Perl2.
. ,
.
,
ctags.
,
Mortice Kern Systems vi DOS
Windows, MKS Toolkit
MKS Vi. Mortice Kern Systems.
, . Perl, 5- .
. . -, 2009.
, , Perl,
3- . . . -, 2002.
144
7.
.
,
,
. vi .
, :
:set autoindent
.
ENTER
,
.
,
, .
autoindent CTRL-T
, CTRL-D
.
, CTRL-T CTRL-D ,
,
.
CTRL-D1:
^ ^D
^ ^D (^ CTRL-D), vi
, .
.
C
C/C++.
0 ^D
0 ^D vi .
,
2.
autoindent .
.
, C,
(})
.
>> <<. >>
1
elvis .
nvi 1.79 ,
, .
145
( ), <<
. ,
>>, , . <<,
.
, >> <<.
,
5>>. .
(
). :
:set shiftwidth=4
, shiftwidth
.
vi . ,
,
. UNIX, ,
UNIX .
, tabstop. ,
, ,
.
:
:set tabstop=4
. vi
tabstop,
UNIX 1 .
: ,
, more,
.
UNIX, .
,
. ,
, .
:
:set list
, : UNIX,
, .
tabstop vi . . .
.
146
7.
,
^I, $.
. :l.
, :
:5,20 l
5- 20-.
(, [, { < .
, %
: ), ], }
> 1. ,
( :
if ( cos(a[i]) == sin(b[i]+c[i]) )
{
printf("cos and sin equal!\n");
}
%, .
, ,
.
,
, %
. ,
printf %.
vi .
, %
! ,
>, %
.
%
,
. , {
C, % }, , ,
. , , - .
} , vi .
1
< > %
nvi. vile (Vim. . . .)
, ,
%.
147
, ,
:
:set showmatch
showmatch ( sm) % ,
. ) }1
( {,
. ,
.
, vi . Vim 7.0
, matchparen.
C C++
. ,
. , UNIX
ctags :tag vi.
UNIX- ctags C , , Pascal
Fortran 77. . C++,
, . ,
tags C++
.
.154.
ctags UNIX.
,
vi ,
. tags. vi
:
:!ctags file.c
tags,
, file.c.
:!ctags *.c
tags, C
.
, tags
, C.
,
, , . vi:
:tag name
1
148
7.
tags , name.
name. ,
. , .
vi.
, ,
^]. vi ,
. vi ,
, , .
:tag
,
, vi .
:w :tag,
:
:tag! name
vi .
vi Solaris ,
Solaris. ,
, vi ,
.157,
.
8
8.
vi
: ,
vi. D -,
, II
Vim. III vi:
nvi 1.79 (Keith Bostic) (16)
elvis 2.2.0 (Steve Kirkendall) (17)
vile 9.6.4 (Kevin Buettner), (Tom
Dickey), (Paul Fox) (Clark Morgan)
(18)
-
vi,
-UNIX , - , vi (
!) UNIX .
, vi UNIX
. (,
, .)
vi
UNIX. , ,
-, .
,
.
. ,
, , .
,
II, Vim,
III. :
150
8. vi
()
/ .
. , vi.
, nvi,
X Window. X,
GUI-
xterm ( ). ,
GUI- ,
.
GUI .
vi
,
egrep UNIX.
.147,
ctags. vi
(tag stack),
.
.
, (LIFO),
.
vi
ctags ,
ctags. ,
,
C++, .
vi
ex, ,
( 8-
), ,
,
.
--.
151
elvis, Vim vile ,
.
.
, vi,
,
.
.
,
. vi
.
,
: .
.
, .
.
,
.
. , ,
, .
. ,
. ,
, .
, , (
) .
.
.
,
,
.
vi ex ,
, .
Vim 11.
III, ,
(
) ,
.
152
8. vi
elvis, Vim vile
(GUI),
. X Window UNIX Mic
rosoft Windows . . 8.1
GUI, vi.
8.1. GUI
X11 Microsoft OS/2 BeOS Macin Amiga QNX OpenVMS
Windows
tosh
Vim
nvi
elvis
vile
, vi
, 6 ,
.95.
vi ,
, . ,
( ) egrep.
,
vi .
,
nvi.
.198
Vim, III, vi,
, .
POSIX, nvi
Extended Regular Expressions (ERE). ,
set extended .nexrc,
ex.
, 6,
POSIX,
POSIX .97 ,
:
|
. , a|b
a, b.
: house|home house, home.
153
(...)
,
. , house|home
( ) ho(use|me). *
: (house|home)* home,
homehouse, househomehousehouse ..
extended , ,
, \(...\)
vi: , ,
/1, /2 ..
\(.
+
. ,
, .
+ *. * , +
. , ho(use|me)*
ho, home, house, ho(use|me)+ ho.
?
. ,
, . , free?d
fred, freed.
{...}
.
. n m
:
{n}
n
. , (home|house){2} homehome, home
house, househome, househouse .
{n,}
n
. ,
n .
{n,m}
n m. ,
,
1.
1
154
8. vi
extended ,
nvi \{ \}.
Exuberant ctags ctags,
, ctags UNIX. tags
,
. Exuberant ,
vi.
,
:tag ^] .
vi.
Exuberant ctags
Exuberant ctags (Darren
Hiebert) 5.71.
http://ctags.sourceforge.net/.
README ctags:
C
C++, , ,
(enum), (,
enum), (), /
(), ,
(struct), (typedef),
(union) . !
C C++.
29 , C# Java.
,
, #if.
, .
GNU Emacs (etags).
Amiga, Cray, MS-DOS, Macintosh, OS/2, QDOS, QNX, RISC
OS, UNIX, VMS Windows 95 XP. -
.
Exuberant ctags tags ,
.
5.8. . . .
155
, tags ,
: ( ), ,
, , .
, ,
vi nomagic
. ,
tags .
UNIX ctags.
vi (
). ,
: ,
(;"),
( ,
.exrc).
.
: , . Exuberant
ctags , .
;" .
, .
, , . .8.2
.
8.2. ctags
kind
,
. f , v ..
kind,
(
, f ).
file
( ) .
.
( file:),
, ( ).
tags,
. ,
,
, tags.
function
.
, .
struct
struct. .
156
8. vi
8.2 ()
enum
enum,
.
class
- - C++. .
scope
- C++.
private
,
.
arity
. .
, ,
kind. :
ARRAYMAXED
AVG_CHAIN_MAX
array.c
awk.h
array.c
array.c
427;"
38;"
1;"
d
d
F
file:
. , Vim
!_TAG_FILE_SORTED tags
, .
tags, Exuberant
ctags.
157
ex :tag ^] vi
,
tags.
,
. ex :tag ^]
vi
.
, ( ) vi ^T ex.
Solaris vi
. Vim .302.
, ,
III.
Solaris vi
, vi Solaris .
, ,
ex(1) vi(1) Solaris.
Solaris vi .8.3, 8.4 8.5.
Solaris vi 1.
8.3. vi Solaris
8.4. vi Solaris
^]
tags ,
, .
,
.
^T
,
.
.
.
158
8. vi
8.5. vi Solaris
taglength, tl
. , , ,
.
, .
"tags/ usr/lib/tags".
tags, tagpath
tagstack
true (), vi
. ,
:set notagstack.
getopt.h
getopt1.c
main.c
tags
/getopt_
^]
int
getopt_long (int argc, char *const *argv, const char *options,
const struct option *long_options, int *opt_index)
{
return _getopt_internal (argc, argv, options, long_options,
opt_index, 0);
}
"getopt1.c" 192L, 4781C
getopt_long. Vim get
opt1.c getopt_long.
159
, getopt_long - _getopt_
internal. _getopt_internal
.
3jf_ ^]
int
_getopt_internal (int argc, char *const *argv, const char *optstring,
const struct option *longopts, int *longind, int long_only)
{
int result;
getopt_data.optind = optind;
getopt_data.opterr = opterr;
result = _getopt_internal_r (argc, argv, optstring, longopts,
longind, long_only, &getopt_data);
optind = getopt_data.optind;
"getopt.c" 1225L, 33298C
getopt.c.
struct option, option
.
jfo; ^]
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
const char *name;
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
"getopt.h" 177L, 6130C
struct option getopt.h.
,
.
:tags
#
1
2
3
TO tag
FROM line in file/text
1 getopt_long
310 main.c
1 _getopt_internal
67 getopt1.c
1 option
1129 getopt.c
:tags Vim .
160
8. vi
^T main.c, .
.
vi ,
:
ex
ex ,
ex.
,
.
.
, 8-
.
.
.
/
,
.
,
- .
(
), .
,
csh, tcsh, ksh, zsh bash ,
, .
,
. , vi UNIX
ex.
vi.
, .
161
. ,
(, )
.
.
, Vim,
. 293.
III.
vi 1.
, 1000
, .
, 8- ,
, 8-
.
. .
, , .
nvi
.
, ex.
elvis
UNIX
. elvis.brf
binary, (
elvis.brf hex
.374).
Vim
. binary,
Vim nvi
.
-b :set binary.
Vim,
.
vile
, ex.
, . vi
. ,
1
162
8. vi
, . nvi Vim
vi . Vim
, binary. elvis vile
.
vi UNIX
- .
, .
,
. ENTER 1.
,
. , ,
.
nvi, Vim elvis ,
vile vi. vile
,
. .8.6 ,
.
8.6.
nvi
searchincr
, ,
.
Vim
incsearch
. Vim ,
.
elvis
incsearch
.
elvis ,
.
vile
^X S, ^X R
,
,
. ^X S
, ^X R .
Emacs .
163
-
vi
. ,
.
,
, .
,
. vi.
, , , ,
. vile ,
. .8.7
.
8.7.
nvi
elvis
Vim
vile
.
,
.
16 .
.
sidescroll = 8 wrap
,
.
8 .
.
sidescroll = 0 wrap
,
. sidescroll
,
.
.
.
sideways = 0
linewrap
,
.
.
< >. side
ways ,
1/3.
.
horizscroll .
, ,
, .
,
. .
sidescroll = 16 leftright
164
8. vi
vile : ^X ^R ^X ^L.
,
. ,
, .
, vi ,
, ,
, . ,
d/^} ,
. elvis vile ,
, . ,
. , Vim, .
.197. . III.
, vi
. ,
. , ,
, ^G ex :=.
: showmode ruler.
vi ,
showmode Solaris.
.8.8 .
8.8.
ruler
showmode
nvi
,
,
elvis
Vim
vile
, ,
vi
, , , ,
, ,
elvis
.
165
vi .
, UNIX-
, C troff (
troff).
, ,
1.
( ) :
-
elvis, Vim vile make,
, .
make. , .
elvis, Vim vile /
.
-
-
-, ,
, .
,
( / )
.
elvis, Vim vile
. ,
2.
.
elvis. C++
:
:w hello.C
#include <iostream>
int main()
{
vi , Emacs.
166
8. vi
:make hello
g++
hello.C -o hello
hello.C:5: error: missing terminating " character
hello.C: In function 'int main()':
hello.C:6: error: expected primary-expression before 'return'
hello.C:6: error: expected `;' before 'return'
make: *** [hello] Error 1
:make, make, ,
, C++ ( g++).
g++ .
#include <iostream>
int main()
{
std::cout << "hello, world\n ;
return 0;
}
~
line 5: missing terminating " character
5,8
Command
make , elvis
, ,
.
, ,
:make , , , .
vi .
, ,
. , Vim,
Vim .314.
III.
elvis, Vim vile
. ,
,
(, X11 Linux).
Vim,
.305.
III.
167
:
vi ,
. .8.9 ,
. ,
; .
8.9.
nvi
elvis
vim
vile
GUI
8-
/
-
vi
,
UNIX.
,
. vi,
.
2002 V7 32V UNIX
1 .
, BSD UNIX, ex vi.
, GNU/Linux,
,
2. , .
1
. .
168
8. vi
, vi,
.
http://ex-vi.sourceforge.net/.
II Vim .
, ,
Vim,
.
III nvi, elvis vile.
:
1. .
2. .
3. - .
4.
.
5. .
6. , .
7. .
8. ( ,
..).
9. ( -
, ).
10. , .
11.
.
gzip, GNU zip.
, ftp://ftp.gnu.org//gnu/gzip/gzip-1.3.12.tar1.
untar.c, FTP- elvis,
gzip tar
-UNIX .
, III,
, ,
.
, , , ,
.
- ,
- .
1
. .
II
II.
Vim
9
9.
Vim vi.
vi,
.
Vim .
:
vi
Vim
(GUI) Vim
Vim vi improved vi.
(Bram Moolenaar).
Vim, , vi.
- (vim.org).
7.11.
, Vim
.
,
, ,
.
7.3. . .
.
172
Vim . ,
, ,
. ,
-
C, C++, Java, C#.
Vim ,
. ,
,
. 10
, Vim .
,
UNIX (, BSD GNU/Linux),
vi. ,
GNU/Linux Vim
/bin/vi!
Vim vi,
,
, , ,
, .
1
(Bram) Vim ,
Amiga. UNIX, vi-
stevie,
. , ,
vi.
,
Vim 1.14 Fred Fish disk 591 (
Amiga).
, ,
. UNIX
MS-DOS , Vim
vi.
: , ..
Vim,
vi.
.
1
,
(Bram Moolenaar), Vim.
.
173
Vim
vi, -
.
Vim
, ,
, Vim.
,
. ,
, .
Vim . ,
, .
.
Microsoft Windows ,
,
vi .
Vim?
Vim vi ,
Vim?. vi ,
(vile, elvis, nvi), Vim
.
,
, Vim
. , (Bram),
,
, , ,
.
vi
Vim vi.
Vim,
, vi UNIX UNIX-
.
vi , .
POSIX . ,
vi, Vim,
,
, ,
vi.
Vim
.
( UNIX, wc -c *.txt)
129 , 122000
! Vim.
174
help
, vi.
Vim, ,
.
Vim vi
. ,
Vim not in vi
not available in vi. (
grep -i 'not *in vi') 700.
, , Vim
, vi.
Vim.
,
, ,
,
,
. , , Vim
,
.
Vim ,
.
vi,
, vi . ,
Vim, ,
Vim .
:
Vim
.
, ,
, , Vim
. ,
.
Vim ,
,
(IDE).
, ,
--
. , Vim
, .
175
(GUI)
Vim,
, ,
.
, ,
, GUI
.
Vim
. ,
,
.
Vim, vi,
, Vim
.
, vi, ,
.
, ,
, ,
-
.
Vim .viminfo. -
: ?
? Vim
,
. , ,
,
, (, )
,
(,
..). Vim
,
. ,
( y [yank]
d [delete]) . ,
, ,
. ,
,
n ( )
.
Vim ,
.
176
25,
.
, Vim
, .
, ,
, ,
,
.
.
Vim .
( )
Vim -
.
. ,
gzip-, myfile.tar.gz, . Vim
,
.
Vim ,
:
(%), (#), ,
(:),
(.,).
,
. ,
,
. Vim
,
.
UNIX, /dev/
null Vim.
Vim
, . ,
, ,
.
Vim vi
compatible (:set compatible). ,
Vim
177
Vim,
,
.
Vim vi.
, (
), ,
,
( ^X^C).
, ,
.
Vim ,
(GUI, )
(,
, ).
, , Vim
. (
) .
Vim ,
.
Vim
UNIX, Mac
OSX, , Vim , , .
PATH,
vim .
UNIX :
sh: command not found: vim
vi ,
Vim. ,
vi.
Vim.
,
. , :version
, Vim,
. , :
:version
VIM - Vi IMproved 7.0 (2006 May 7, compiled Aug 30 2006 21:54:03)
Included patches: 1-76
Compiled by corinna@cathi
Huge version without GUI. Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
178
10,
Vim .
, Mac Mini OS X 10.4.10
vi Vim,
(man-) Vim!
Vim,
, .
, PATH,
:
/usr/bin ( PATH)
/bin ( )
/opt/local/bin
/usr/local/bin
, , , Vim
. ,
( ) .
, Vim ,
, Vim :
UNIX , GNU/Linux
Windows XP, 2000, Vista
Macintosh
179
UNIX,
(, Sun Solaris, HP-UX,
*BSD, GNU/Linux),
Vim ,
1.
,
.
UNIX ,
( Ubuntu GNU/Linux)
, .
Vim
,
aap. aap ,
,
aap .
, , aap
.
Vim
GNU/Linux (RPM Red Hat, DEB
Debia n), IRIX (SoftwareManager), Sun Solaris (Companion Soft
ware) HP-UX. Vim
.
.bz2
$ bunzip2 vim-7.1.tar.gz
vim-7.1.tar (
, ).
tar:
$ tar xvf vim-7.1.tar
vim71
vim71/README.txt
1
GNU/Linux, Vim
.
. . . .
180
vim-7.1.tar 1. Vim,
tar:
$ cd vim71
configure , .
.
, .
,
() . ,
Vim Perl (
configure ) ,
Perl- Vim:
$ ./configure --enable-perlinterp
Perl ,
configure:
$ ./configure --disable-perlinterp
Vim
. --disableXXX --enable-XXX configure, INSTALL
feature.h.
, Vim
( README.txt)
Vim.
configure ( )
:
1
GNU
tar, tar xvf ;
. . . .
Vim make:
$ make
Starting make in the src directory.
If there are problems, cd to the src directory and run make there
cd src && /usr/local/lib/cw/make first
/home/ehannah/Desktop/vim/vim71/src
make[1]: Entering directory `/home/ehannah/Desktop/vim/vim71/src'
gcc -c -I. -Iproto -DHAVE_CONFIG_H
-g -O2
-o objects/
charset.o charset.c
gcc -c -I. -Iproto -DHAVE_CONFIG_H
-g -O2
-o objects/
diff.o diff.c
gcc -c -I. -Iproto -DHAVE_CONFIG_H
-g -O2
-o objects/
digraph.o digraph.c
gcc -c -I. -Iproto -DHAVE_CONFIG_H
-g -O2
-o objects/
edit.o edit.c
...
make[2]: Entering directory `/home/ehannah/Desktop/vim/vim71/src'
creating auto/pathdef.c
gcc -c -I. -Iproto -DHAVE_CONFIG_H
-g -O2
-o objects/
pathdef.o auto/
pathdef.c
make[2]: Leaving directory `/home/ehannah/Desktop/vim/vim71/src'
link.sh: Using auto/link.sed file to remove a few libraries
gcc
-o vim objects/buffer.o objects/charset.o objects/diff.o
objects/digraph.o objects/edit.o objects/eval.o objects/ex_cmds.o
objects/ex_cmds2.o objects/ex_docmd.o objects/ex_eval.o
objects/ex_getln.o objects/fileio.o objects/fold.o objects/getchar.o
181
182
, src
Vim. ,
,
Vim .
, ,
.
Vim
, (root).
, root :
# make install
Starting make in the src directory.
If there are problems, cd to the src directory and run make there
cd src && make install
/home/ehannah/Desktop/vim/vim71/src
make[1]: Entering directory `/home/ehannah/Desktop/vim/vim71/src'
if test -f /usr/local/bin/vim; then \
mv -f /usr/local/bin/vim /usr/local/bin/vim.rm; \
rm -f /usr/local/bin/vim.rm; \
fi
cp vim /usr/local/bin
strip /usr/local/bin/vim
chmod 755 /usr/local/bin/vim
cp vimtutor /usr/local/bin/vimtutor
chmod 755 /usr/local/bin/vimtutor
/bin/sh ./installman.sh install /usr/local/man/man1 "" /usr/local/
share/vim /usr/local/share/vim/vim71 /usr/local/share/vim ../
runtime/doc 644 vim vimdiff evim
installing /usr/local/man/man1/vim.1
installing /usr/local/man/man1/vimtutor.1
installing /usr/local/man/man1/vimdiff.1
...
Vim Windows
183
; PATH
, Vim.
Vim Windows
Microsoft Windows .
gvim.exe,
Vim. , .
Vim exe- Windows,
.
Windows XP, 2000, NT, ME, 98 95.
DOS,
, - .
.
Windows Cygwin
(http://www.cygwin.com/) GNU,
Windows.
, UNIX.
Vim Cygwin,
Cygwin.
Vim Macintosh
Mac OS X Vim 6.2, -
. .tar.bz2,
6.4 7.3, GUI.
184
(maintai
ner) Mercurial (
), ,
. ,
.
UNIX,
Vim UNIX GNU/Linux .178.
Vim Cygwin
Vim Cygwin, gvim
Cygwin , X Window System,
gvim ,
Vim.
gvim Cygwin (,
), Cygwin X-,
Cygwin:
$ X -multiwindow &
-multiwindow X, Windows
Cygwin.
X Cygwin,
, Cygwin.
, Cygwin
. Windows
X. , X .
Vim Cygwin www.vim.org
.
, Vim,
,
Vim,
. , Vim Cygwin Vim Windows
, .
Vim ,
Vim , ,
. Vim :
QNX (RTOS)
Agenda
185
, vi, Vim
, Vim
:
Vim (gvim)
gvim ,
Vim ,
,
.
gvim ,
Vim
. vim -g.
Vim (evim)
evim vi
,
. ,
,
vi. vim -e.
vimtutor
Vim vimtutor ,
. Vim
.
vimtutor 30 .
vi
UNIX.
. Vim ,
186
vi.
:
Vim vi,
. ,
vi, Vim
.
vi,
, .
Vim , .
, vi
, Vim
.
. ,
Vim ,
. ,
, !
Vim . ,
, Vim (charityware).
, (Bram Moolenaar)
, Vim,
. ,
(Bram)
.
http://iccf-holland.org/ ,
uganda (:help uganda).
10
10.
Vim
vi
Vim vi,
. vi
( ), Vim .
, Vim ,
vi . :
, Vim
, 100000 .
:help ( ,
Vim).
,
-,
:
,
. .
:help - :
188
10. Vim vi
*help.txt*
k
the cursor keys, or "h" to go left,
h l
to go down, "k" to go up, "l" to go right.
j
":q[Enter]".
":qa![Enter]" (careful, all changes are lost!).
Jump to a subject: Position the cursor on a tag (e.g. |bars|) and hit CTRL-].
With the mouse: ":set mouse=a" to enable the mouse (in xterm or GUI).
Double-click the left mouse button on a tag, e.g. |bars|.
Jump back: Type CTRL-T or CTRL-O (repeat to go further back).
Get specific help: It is possible to go directly to whatever you want help
on, by giving an argument to the |:help| command.
It is possible to further specify the context:
*help-context*
WHAT
PREPEND
EXAMPLE
~
Normal mode command
(nothing) :help x
, Vim
,
, .
,
.
help
Tab Vim.
(:) Tab
. , :
:e /etc/termc[TAB]
UNIX :
:e /etc/termcap
:e , ,
,
, .
:help , .
Vim.
.
, ,
, .
, , . :
:help split
Tab. help
: split(); :split; :split_f; splitview; splitfind; 'splitright'; 'split
189
Vim
. (
, ). (
) -
. Vim ,
. , ,
.
:
,
(
)
Vim.
:
:help startup
Vim
. ,
, .
,
UNIX. - (
), , -b,
. -- ( ), --noplugin,
( ).
, ,
Vim, (
UNIX).
, . (
, -. Vim,
stdin. ,
, .)
190
10. Vim vi
Vim,
vi ( vi Vim):
-b
. .
,
,
.
Vim .
-c command
command ex. vi ,
Vim -c .
-C
Vim (vi) .
vi .
-cmd command
vimrc command.
-c.
-d
diff. Vim ,
,
(scrollbind, foldcolumn ..).
Vim ,
, diff UNIX. Windows
, Vim
.
-E
ex. ,
, .
-F -A
.
.
-g
gvim ( Vim).
-m
. .
-o
.
, .
, ,
( ).
191
, , Vim ,
.
-O
, -o, .
-y
Vim . ,
.
,
.
-z
.
. ,
!G!sort .
sort.
,
Vim. remote
Vim ( , )
,
server , ,
. serverlist
:
-remote file
-remote-silent file
-remote-wait file
-remote-send file
-servername name
-remote-expr expr
-remote-wait-silent file
-remote-tab
-remote-send keys
-remote-wait-silent file
-serverlist
, vi,
.421.
,
Vim : (
X Window System UNIX GUI
) .
. UNIX
,
:
192
10. Vim vi
vim
Vim.
gvim
Vim .
gvim ,
.
vim -g ( UNIX gvim X Window System).
view, gview
Vim gvim .
vim -R.
rvim
Vim .
^Z.
rgvim
, rvim, .
rview
view, ,
,
. vim -Z ( -R
, ).
rgview
, rview, .
evim, eview
. Vim ,
, .
vim -y. ,
,
vi.
, gXXX,
, . , , gvim
,
, --.
vimdiff, gvimdiff
diff ,
.
? .330.
ex, gex
ex.
. vim -e.
193
Windows
Vim ( ).
Vim .
(
, ) . ,
, . :
1. VIMINIT. . , Vim
ex.
2. vimrc. vimrc (Vim re
source) , -
Vim
:
$HOME/.vimrc (Unix, OS/2 Mac OS X)
s:.vimrc (Amiga)
home:.vimrc (Amiga)
$VIM/.vimrc (OS/2 Amiga)
$HOME/_vimrc (DOS Windows)
$VIM/_vimrc (DOS Windows)
:
set
set
set
set
194
10. Vim vi
set
set
set
set
set
wrapmargin=15
nowrapscan " don't scan past end or top of file in searches
ruler
wildchar=<TAB>
more
,
. ,
. ,
,
(") set number .
Vim,
.
,
.
(UNIX ),
, ,
. ,
,
. Vim;
,
.
Windows
:
1. .
2. System.
3. Advanced.
4. Environment Variables.
,
, User System.
. User
, Vim,
.
Unix/Linux Bash Bourne
(,
Bash .bashrc)
:
VARABC=somevalue
VARXYZ=someothervalue
195
MYVIMRC=myfavoritevimrcfile
export VARABC VARXYZ MYVIMRC
. export
, ,
.
, .
Unix/Linux C
(
.cshrc) :
setenv VARABC somevalue
setenv VARXYZ someothervalue
setenv MYVIMRC myfavoritevimrcfile
, Vim
,
Vim, .
Vim -u Vim
. -u , Vim:
SHELL
,
Vim (!!, :! ..). MS-DOS,
SHELL ,
COMSPEC.
TERM
Vim term. ,
,
. , Vim , ,
.
MYVIMRC
Vim. MYVIMRC
, ,
, ,
. (.
).
VIMINIT
, ex Vim.
,
(|).
EXINIT
, VIMINIT.
196
10. Vim vi
VIM
,
Vim ( , Vim
).
Vim,
VIM, ,
. ,
Cygwin VIM /usr/
share/vim, vim.org C:\Program
Files\Vim.
Vim,
!
VIMRUNTIME
Vim, -
, .
. ,
vimrc,
Vim, VIMRUNTIME
, .
Vim vi,
3, ,
.10.1.
10.1. Vim
<C-End>
,
. count,
count.
<C-Home>
.
<C-End>, <C-Home>
.
count%
count- ;
. , Vim
, , .
, ,
200 , 195
(, $4.98), 1000 . UNIX,
,
(195 * (5 + 1)) ( 5- )
197
:go n
n go
n- . ,
.
Vim
. ,
, ,
.
Vim , ,
- ,
Vim,
.
,
.
Vim ,
, .
, .
, v,
.
,
. , (w)
.
.
Vim ,
,
, . ,
, , , .
,
, Vim .
aw ( ).
Vim ,
,
, ,
Vim.
.
v .
198
10. Vim vi
. gvim
. Vim.
.10.2 Vim
.
10.2. Vim
countaw, countaW
count , , ,
. iw (.
). w ,
, W ,
.
countiw, countiW
count .
. w ,
, W .
as, is
a .
ap, ip
.. . . . .
:
:help text-objects
vi Vim
.
Vim:
\|
(house\|home).
\+
.
\=
.
\{n,m}
n m. n m 0 32000.
199
Vim ,
, .
\{n}
n .
\{n,}
, n.
\{,m}
0 m.
\{}
, ( *).
\{-n,m}
n m.
\{-n}
n .
\{-n,}
, n.
\{-,m}
0 m.
\i
isi
dent.
\I
\i, .
\k
iskeyword.
\K
\k, .
\f
isfname.
\F
\f, .
200
10. Vim vi
\p
isprint.
\P
\p, .
\s
(
).
\S
, .
\b
(Backspace).
\e
Escape.
\r
.
\t
.
\n
1.
.
Vim.
~
.
\(\)
*, \+ \=,
(\1, \2 ..).
\1
,
\( \). , \([a-z]\).\1 ata, ehe, tot
.. \2, \3
, .
isident, iskeyword, isfname isprint
, ,
.
.
Vim 7.3 . . . .
201
Vim
.
.
.
Vim ,
Linux,
.
, (
, , ,
) perl (- ,
perl ).
, ,
Vim ,
.
11
11.
Vim
Vim ,
. Vim
, . ,
Vim .
Vim ( ).
,
. , ,
. ,
.
,
:
,
.
.
.
,
.
.
Vim ,
, :
.
.
203
.
.
, ( ).
, diff,
.
,
, ,
, ,
, (
, !). :
.
:ex .
.
.
.
.
( -
).
.
Vim,
. Vim
, ,
.
()
Vim ,
.
, Vim
, , , ,
vi.
, ( ).
,
Vim -o. :
$ vim -o file1 file2
204
11. Vim
,
(.11.1).
, , Vim
.
, ,
, ,
( ).
-o n,
:
$ vim -o5 file1 file2
,
,
file1, file2 (.11.2).
Vim ,
(
).
Vim laststatus, :
:set laststatus=1
laststatus 2, ,
( .vimrc).
205
, ,
, , Vim
. Vim winheight winwidth
(
, ).
Vim
Vim. :split.
.
.
. , ^Ws
( Vim, , ^W,
W window).
,
,
. ,
,
Vim,
.187.
206
11. Vim
.11.3.
, ,
:vsplit (.11.3).
Vim (
), :split
, .
,
?
,
. . . .
?
:
C ,
( , ,
--help). ,
,
,
, . (
)
,
.
,
,
:split. :
:split otherfile
,
.
207
,
:split ( ) :vsplit
( ).
.
.
:split, ,
:
:[n]split [++opt] [+cmd] [file]
n
Vim, ,
.
opt
Vim
( , opt ).
cmd
, (
, cmd ).
file
, .
, ,
otherfile. ,
fileformat, unix
( UNIX,
,
). 15. :
:15split ++fileformat=unix otherfile
,
,
^Ws, ^WS ^W^S.
equal
always. .vimrc,
.
equalalways
. ,
, eadirection
( hor, ver both
, , ).
208
11. Vim
:split
, :
:[n]new [++opt] [+cmd] [file]
WinLeave,
WinEnter, BufLeave BufEnter (
.237).
Vim
. ,
:split :new
:vsplit :vnew .
,
.
,
:
:sview filename
, ,
. :sview
.
:sfind [++opt] [+cmd] filename
:split, filename path. Vim
, .
Vim , ,
. :topleft cmd
cmd ,
cmd .
:
cmd ,
Vim.
cmd ,
Vim.
cmd ,
.
:topleft Vim
: :leftabove, :rightbelow, :botright :ver
tical.
Vim, :help.
11.1 .
( )
209
11.1.
ex
vi
^Ws
^WS
W^S
^Wn
^W^N
( ),
.
file
.
,
.
, :split,
.
,
,
.
:split --.
file
( )
. file path.
^Wv
^W^V
( )
file ( )
.
:new.
( )
gvim, Vim. gvim ,
Vim mouse.
:set mouse=a,
: , ,
.
, Vim
. ,
^W.
.
vi Vim,
.
,
, .
210
11. Vim
Vim , CTRL-W j
( CTRL-W < >, CTRL-W CTRL-J). CTRL-W
window, j Vim j,
.
.11.2 .
Vim vi,
, .
, 3^Wj Vim .
11.2.
.
,
.
.
, .
,
: ,
,
(
CTRL-W CTRL-W).
.
CTRL-W j.
,
.
CTRL-W w
CTRL-W CTRL-W
.
, ,
CTRL-W j,
Vim.
Vim
,
.
CTRL-W W
,
.
CTRL-W w.
211
CTRL-W t
CTRL-W CTRL-T
CTRL-W b
CTRL-W CTRL-B
,
.
CTRL-W p
CTRL-W CTRL-P
(
).
t b (top) (bottom) .
,
, ,
CTRL-W w,
CTRL-W W.
Control .
, Shift CTRL
. ( Cont
rol) .
Vim .
, .
,
. ,
, , .
( )
, .
: , ( ),
, , .
, .
CTRL-W r .
CTRL-W R,
.
,
Vim . CTRL-W r
212
11. Vim
,
, . CTRL-W R
.
, ,
.
Vim , ,
,
.
CTRL-W x CTRL-W CTRL-X
. Vim
, , .
n- , . ,
, 3^Wx.
, ,
.
:
( )
,
,
,
(. .222).
Vim:
CTRL-W K k .
.11.3.
11.3.
^WK
^WJ
^WH
^WL
^WT
,
.
,
.
,
.
,
.
.
.
Vim
,
.
.
213
:
11.4 11.5 , .
11.4.
^Wr
^W^R
^WR
^Wx
^W^X
, n,
n- .
11.5.
^WK
. .
^WJ
. .
^WH
. .
^WL
.
.
^WT
.
.
, .
,
Vim, .
, , , ,
.
, Vim
.
,
, gvim, .
,
. , ,
|.
.
214
11. Vim
, Vim
.
, CTRL-W
,
.
CTRL-W = (
winheight windwidth,
).
, Vim
.
CTRL-W . Vim
ex, . ,
resize -4 ,
.
, Vim ,
.
,
,
. ,
, , (
Vim
1). :resize
,
cmdheight.
CTRL-W + ,
:resize +n n .
, .
CTRL-W+
CTRL-W .
+. Vim ,
2 Vim (
j). ,
- ,
1
- (,
:buffers) , Vim
Press ENTER or type command to continue ( ENTER
).
. . . .
, + j : +
. + Enter
^M. . . .
215
CTRL-W +. + ( )
. () Shift, + Shift, ,
Shift, _.
, ,
.
:resize n
n . ,
, .
zn n. ,
n ! ,
vi/Vim z, .
CTRL-W < CTRL-W >
. (<<)
(>>), .
, CTRL-W | ,
( 1).
vertical
resize n, n .
Vim
, .
, winheight winwidth
. ,
45, Vim
. winheight ,
45, 60,
60 ,
30. ,
.
equalalways Vim
. ,
.
eadirection , equal
always. : hor, ver both. Vim
,
.
.
1
, ,
.
^W_; . .
. .
216
11. Vim
cmdheight .
, ,
, .
.
, winminwidth winminheight
Vim. , ..
, .
. 11.6 .
:set.
11.6.
^W=
.
winheight winwidth.
:resize -n
^W-
.
.
:resize +n
^W+
.
.
:resize n
^W^_ ^W_
.
( n).
zn <ENTER>
n.
^W<
. .
^W>
. .
:vertical resize n
^W|
winheight,
n.
.
winwidth,
equalalways, -
, .
eadirection, Vim:
, .
cmdheight,
winminheight,
,
.
winminwidth, ,
.
217
Vim .
.
,
, , ,
Vim.
. ,
Vim, file1, :split
file2, :split file3. ,
Vim.
:ls, :files :buffers,
. ,
. Vim
. ,
, , .
file1 1, file2 2 ..
(!),
.
.
, .11.7.
11.7. ,
.
, !.
, :help. Vim
,
. :ls
, :ls! .
% (
) #
% , # ,
:edit #.
a (
) h
a . ,
. h .
, .
- (
) =
- ,
modifiable.
. = ,
(, -
).
+ (
) x
+ , , x
.
218
11. Vim
u ,
Vim . ,
:help, :ls!, ,
windows.txt Vim.
, Vim,
.
Vim
Vim .
. , ,
, . ,
.
Vim:
quickfix
, 1 (
:cwindow), (
:lwindow).
!
--.
14.
help
Vim,
.187. :help
.
directory
,
( ). Vim
ENTER, .
scratch
.
, .
Vim,
.
, ,
. ,
1
, :make, 8. . . .
219
, myfile,
myOtherfile. hidden,
myOtherfile, :edit myOtherfile.
Vim myfile myOtherfile.
, :ls ,
myfile .
50 , .
,
.
, Vim .
, .
, ,
.
-
:
windo cmd
window do (, ,
). (
) cmd
.
(^Wt) ,
:cmd.
, :cmd .
, , .
cmd ,
, .
cmd ,
(|). ,
UNIX !
,
, ..
:windo ,
Java, -
. ,
myPoorlyCapitalizedClass MyPoorlyCapi
talizedClass. :windo:
:windo %s/myPoorlyCapitalizedClass/MyPoorlyCapitalizedClass/g
220
11. Vim
.11.8 ,
. ,
, .
11.8.
:ls[!]
:files[!]
:buffers[!]
:ball
:sball
:unhide
:sunhide
:badd file
:bunload[!]
.
, !.
:bdelete[!]
:buffer [n]
:sbuffer [n]
:bnext [n]
:sbnext [n]
:bNext [n]
:sbNext [n]
:bprevious [n]
:sbprevious [n]
:bfirst
:sbfirst
:blast
:sblast
:bmod [n]
:sbmod [n]
Vim (args)
(sball ).
(sunhide
).
file .
. !
.
.
! .
n (sbuffer ).
n- (sbnext
).
n- . (sbNext sbprevious .)
(sbfirst ).
(sblast ).
n- (sbmod
).
221
Vim vi ,
, .
.
, , ,
.
:stag[!] tag ,
. , ,
, .
, , .
Vim,
:stag,
.
^W] ^W^] .
,
. ,
.
^Wg] .
Vim :tselect tag, tag
. ,
. ,
.
^Wg^] ^Wg], :tselect tjump.
^Wf ( ^W^F) .
Vim , path
.
path, , .
^WF .
,
, .
^Wgf .
, .
^WgF
, .
.
222
11. Vim
,
? Vim ,
.
, , ,
, ,
, .
Firefox 1
- . ,
. ,
, .
Vim, gvim,
gvim .
:
:tabnew filename
().
, Vim .
:tabclose
.
:tabonly
.
, , ,
autowrite (
).
gvim
.
, (
mouse).
CTRL PAGE DOWN ( )
CTRL PAGE UP ( ).
, Vim
.
gvim ,
(
) .
. 11.4 (
).
, . .
. .
223
.11.4. gvim
,
: , ,
.
^Wq ( ^W^Q, :quit) :quit.
( )
, vi :quit. hidden
,
, ,
( ) . , Vim
,
. hidden , ,
,
, , .
- ,
.
^Wc ( :close[!]) .
hidden , , Vim
.
,
, . !,
. ! Vim .
, ^W^C,
Vim ^C .
, ^W^C, ^C
.
^W ^S ^Q
, ,
^S ^Q
.
,
.
224
11. Vim
:quit[!]
^Wq
^W^Q
:close[!]
^Wc
:only[!]
^Wo
^W^O
.
.
, Vim
.
, . , Vim
, , Vim
.
, Vim ,
, .
12
12.
Vim
. Vim .vimrc,
, ,
. Vim .
,
.
Vim (.vimrc, .gvimrc ),
Vim, .
Vim . ,
, Vim
(if...then...else, while ..),
, .
,
,
Vim.
?
. ,
Vim, .
Vim 17 .
, .vimrc
.gvimrc colorscheme.
(desert) :
colorscheme desert
226
12. Vim
colorscheme ,
Vim .
, .
? ?
? Vim
.
, , .
Google iGoog
le .
,
.
darkblue
6 .
morning
6 .
shine
6 .
evening
6 .
if...then...else...,
.
, :
if cond expr
line of vim code
another line of vim code
...
elseif some secondary cond expr
code for this case
else
code that runs if none of the cases apply
endif
elseif else ,
elseif. Vim C:
cond ? expr 1 : expr 2
cond. ,
expr 1, expr 2.
227
strftime( )
, ,
. Vim ,
.
strftime(). ,
( 1
, .
,
). ,
1970 (
C).
. %H,
strftime("%H"),
, .
,
Vim, ,
.
.vimrc :
" progressively check higher values... falls out on first "true"
" (note addition of zero ... this guarantees return from function is numeric
if strftime("%H") < 6 + 0
colorscheme darkblue
echo "setting colorscheme to darkblue"
elseif strftime("%H") < 12 + 0
colorscheme morning
echo "setting colorscheme to morning"
elseif strftime("%H") < 18 + 0
colorscheme shine
echo "setting colorscheme to shine"
else
colorscheme evening
echo "setting colorscheme to evening"
endif
,
Vim echo. .
,
. Vim
,
echo.
colorscheme ( desert)
, echo
("desert"). !
1
, Vim strftime()
C,
. . . .
228
12. Vim
colorscheme
Vim.
. ,
colorscheme . ,
.
, echo
(, )
. ,
.
, , , ,
. ,
- ,
, strftime() .
, ,
,
.
,
Vim.
.
Vim , ,
.
.
, .
:
b:
Vim.
w:
Vim.
t:
Vim.
g:
,
.
l:
( ).
s:
Vim.
a:
.
229
v:
Vim (
).
,
(g:),
, (l:), .
let:
:let var = "value"
(
), (
-).
, Vim
. currentHour.
strftime() ,
:
" progressively check higher values... falls out on first "true"
" (note addition of zero ... this guarantees return from function is numeric)
let currentHour = strftime ("%H")
echo "currentHour is " currentHour
if currentHour < 6 + 0
colorscheme darkblue
echo "setting colorscheme to darkblue"
elseif currentHour < 12 + 0
colorscheme morning
echo "setting colorscheme to morning"
elseif currentHour < 18 + 0
colorscheme shine
echo "setting colorscheme to shine"
else
colorscheme evening
echo "setting colorscheme to evening"
endif
,
, colorScheme.
, . S ,
colorscheme,
, ,
Vim , ,
.
(.) echo.
,
echo. "setting co
lor scheme to " , colorScheme.
230
12. Vim
" progressively check higher values... falls out on first "true"
" (note addition of zero ... this guarantees return from function is numeric
let currentHour = strftime("%H")
echo "currentHour is " . currentHour
if currentHour < 6 + 0
let colorScheme ="darkblue"
elseif currentHour < 12 + 0
let colorScheme = "morning"
elseif currentHour < 18 + 0
let colorScheme = "shine"
else
let colorScheme = "evening"
endif
echo "setting color scheme to" . colorScheme
colorscheme colorScheme
,
. , .
.
execute
,
.
.
,
(colorScheme)
,
colorscheme colorScheme
, .12.1.
Vim,
, , darkblue.
execute.
,
. , ,
231
,
colorscheme:
execute "colorscheme " . colorScheme
( )
. execute ,
colorscheme , .
. , execute colorscheme,
.
, .
. ,
.
colorScheme ,
. execute
:
,
execute .
, , . exe
cute , .
execute , Vim
.
Vim ,
. colorscheme
colors_name.
echo , echo
colors_name. ,
colorscheme, :
echo colors_name
. ,
,
Vim. ,
,
.
function...endfunction, Vim
.
:
function myFunction (arg1, arg2...)
line of code
another line of code
endfunction
232
12. Vim
. ,
,
:
function SetTimeOfDayColors()
" progressively check higher values... falls out on first "true"
" (note addition of zero ... this guarantees return from function is numeric)
let currentHour = strftime("%H")
echo "currentHour is " . currentHour
if currentHour < 6 + 0
let colorScheme = "darkblue"
elseif currentHour < 12 + 0
let colorScheme = "morning"
elseif currentHour < 18 + 0
let colorScheme = "shine"
else
let colorScheme = "evening"
endif
echo "setting color scheme to" . colorScheme
execute "colorscheme " . colorScheme
endfunction
Vim
.
, .gvimrc.
, .
call. :
call SetTimeOfDayColors()
,
Vim.
call .gvimrc. , ,
.
Vim,
,
,
! ,
.
Vim SetTimeOfDayCo
lors(), .
? , .gvimrc
. ,
, statusline.
233
Vim
. statusline ,
,
, Vim.
,
, Vim statusline
, . Vim
statusline.
. , .
statusline ,
. .
SetTimeOfDayColors()
, .
, ,
,
:
set statusline=%<%t%h%m%r\ \ %a\ %{strftime(\"%c\")}%=0x%B\
\\ line:%l,\ \ col:%c%V\ %P
statusline . Vim
(\)
, .
, ,
.
, statusline.
Vim ,
.
:
ch12.xml
, statusline
.
SetTimeOfDayColors() statusline. +=
, -
:
set statusline += \ %{SetTimeOfDayColors()}
.
,
,
. ?
234
12. Vim
Vim,
.
,
strftime().
, .
statusline ,
, , . ,
,
, .
.
Vim
Vim, .
Vim, -
.
-, -
. ,
,
. ,
. .
,
.
, ,
, , Vim
,
. ,
, ,
. .
,
, .
,
colorscheme: colors_name. :
function SetTimeOfDayColors()
" progressively check higher values... falls out on first "true"
" (note addition of zero ... this guarantees return from function is numeric)
let currentHour = strftime("%H")
if currentHour < 6 + 0
let colorScheme = "darkblue"
elseif currentHour < 12 + 0
let colorScheme = "morning"
235
, , :
, .12.2.
.12.2.
, Vim
. colors_name?
, colorscheme,
, g:,
.
g:colors_name ,
colorscheme.
g:colors_name.
: .gvimrc
let g:colors_name = "xyzzy"
colorscheme default
,
. ,
.
,
if...then...else.
.
236
12. Vim
Vim ,
, .
Favcolorschemes.
, ,
,
.
let g:Favcolorschemes = ["darkblue", "morning", "shine", "evening"]
.gvimrc.
g:Favcolorschemes
. , g:Favcolorschemes[2]
"shine".
Vim
,
( ),
. :
function SetTimeOfDayColors()
" currentHour will be 0, 1, 2, or 3
let g:CurrentHour = (strftime("%H") + 0) / 6
if g:colors_name !~ g:Favcolorschemes[g:CurrentHour]
execute "colorscheme " . g:Favcolorschemes[g:CurrentHour]
echo "execute " "colorscheme " . g:Favcolorschemes[g:CurrentHour]
redraw
endif
endfunction
echo
, . redraw
Vim .
! ,
,
.
. ,
, Vim
filetype, .
, .c , C. Vim
C.
. ,
.sh,
,
237
, . , Vim
,
, .
,
. Vim
!
Vim
, .
, ,
Vim (autocommands).
, Vim.
.
:
BufNewFile
, Vim
.
BufReadPre
, Vim
.
BufRead, BufReadPost
, Vim
, .
BufWrite, BufWritePre
.
FileType
filetype.
VimResized
Vim.
WinEnter, WinLeave
Vim
.
CursorMoved, CursorMovedI
.
238
12. Vim
80 Vim.
autocmd, ,
. autocmd :
autocmd [group] event pattern [nested] command
:
group
( ).
event
, command.
pattern
, ,
command.
nested
,
.
command
Vim, ,
.
, pattern *.
,
. ,
, : Cur
sorMovedI CursorMoved.
CursorMoved ,
,
. CursorMovedI, ,
, , , .
,
. CheckFileType. ,
autocmd. :
autocmd CursorMovedI * call CheckFileType()
CheckFileType filetype.
Vim
.
( filetype) (&).
,
&filetype.
239
CheckFileType:
function CheckFileType()
if &filetype == ""
filetype detect
endif
endfunction
:
#!/bin/sh
inputFile="DailyReceipts"
Vim , .12.3.
, Vim
, - , #!/bin/sh ,
inputFile= , "DailyReceipts" . ,
.
filetype, set filetype, ,
.12.4.
.12.3.
.12.4. conf
240
12. Vim
Vim conf, , . ?
,
, Vim
# CursorMovedI.
UNIX, , #
, Vim , #
.
, Vim .
, .
Vim
, 20.
, Vim
,
CursorMovedI 20.
, ,
.
. b:countCheck.
, 20
(
20), :
function CheckFileType()
let b:countCheck += 1
" Don't start detecting until approx. 20 chars.
if &filetype == "" && b:countCheck > 20
filetype detect
endif
endfunction
, .12.5.
. ,
. ,
b:countCheck.
,
.
241
exists( )
:
Vim ,
- .
,
b:countCheck
:let:
function CheckFileType()
if exists("b:countCheck") == 0
let b:countCheck = 0
endif
let b:countCheck += 1
" Don't start detecting until approx. 20 chars.
if &filetype == "" && b:countCheck > 20
filetype detect
endif
endfunction
. 12.6
20 , .12.7
21- .
/bin/sh .
set filetype , Vim
, .12.8.
.12.6.
.12.7.
.12.8.
242
12. Vim
, Vim
200 :
function CheckFileType()
if exists("b:countCheck") == 0
let b:countCheck = 0
endif
let b:countCheck += 1
" Don't start detecting until approx. 20 chars.
if &filetype == "" && b:countCheck > 20 && b:countCheck < 200
filetype detect
endif
endfunction
, CheckFileType
Vim, ,
,
200. ,
, ,
,
, ,
,
, .
, ,
20 .
.
, ,
,
, CheckFileType()
.
, .
,
#, BACKSPACE
10 . , # ,
() conf.
,
.
,
filetype detect.
? ,
.
,
.
243
,
CursorMovedI . Vim
augroup. :
augroup groupname
autocmd
groupname, :
augroup END
( ,
augroup.)
autocmd :
augroup newFileDetection
autocmd CursorMovedI * call CheckFileType()
augroup END
, CursorMovedI,
newFileDetection.
.
,
, . ,
(
, , ). Vim
, ,
.
autocmd! [group] [event] [pattern]
Vim (!),
autocmd, , ,
, , .
newFileDetection,
,
. :
autocmd! newFileDetection
, newFile
Detection, .
, , ,
Vim (
) :
autocmd newFileDetection
Vim .12.9.
244
12. Vim
200 .
, .
augroup, autocmd
.vimrc :
augroup newFileDetection
autocmd CursorMovedI * call CheckFileType()
augroup END
function CheckFileType()
if exists("b:countCheck") == 0
let b:countCheck = 0
endif
let b:countCheck += 1
" Don't start detecting until approx. 20 chars.
if &filetype == "" && b:countCheck > 20 && b:countCheck < 200
filetype detect
" If we've exceeded the count threshold (200), OR a filetype has been detected
" delete the autocmd!
elseif b:countCheck >= 200 || &filetype != ""
autocmd! newFileDetection
endif
endfunction
,
, , ,
:
autocmd newFileDetection
Vim .12.10.
.12.10.
, Vim
245
, newFileDetection
.
:
augroup! groupname
, Vim
. ,
, .
.
! Vim.
Vim ,
.
,
Vim
Vim, , .
.
,
Vim,
.
Vim
Vim , ,
, .
meta HTML,
,
.
( ):
autocmd BufWritePre,FileWritePre *.html mark s|call LastMod()|'s
fun LastMod()
" if there are more than 20 lines, set our max to 20, otherwise, scan
" entire file.
if line("$") > 20
let lastModifiedline = 20
else
let lastModifiedline = line("$")
endif
exe "1," . lastModifiedline . "g/Last modified: /s/Last modified:
246
12. Vim
.*/Last modified: " .
\ strftime("%Y %b %d")
endfun
autocmd:
BufWritePre, FileWritePre
, . Vim
.
*.html
,
.html.
mark s
.
ks , mark s.
s,
.
|
Vim,
. ,
UNIX.
call LastMod()
LastMod.
|
.
's
s.
,
.html, Last modified:
w.
,
HTML meta.
,
content=....
.
Vim
. Vim :
, Vim
247
Number
32- .
, (, 0xffff)
(, 0177) .
String
.
Funcref
.
List
Vim- .
Vim.
Dictionary
Vim- ,
. ,
,
.
Vim ,
, , ,
. ( )
, 0:
if strftime("%H") < 6 + 0
.
, ,
, ,
.
, Vim
.
, ,
.
Vim
,
Perl, Python Ruby.
Vim.
248
12. Vim
autocmd
, .236,
Vim autocmd ,
. ,
autocmd. ,
Vim
.
shiftwidth
. ,
,
. , HTML shiftwidth
2, ,
C shiftwidth, 4.
, .vimrc .gvimrc :
autocmd BufRead,BufNewFile *.html set shiftwidth=2
autocmd BufRead,BufNewFile *.c,*.h set shiftwidth=4
Vim 200
.
, ,
. usr_41.txt
Vim:
,
,
.
.
, Perl.
( )
, ,
, . -
Perl.
(getter) (setter),
Vim.
type, .
,
.
, Vim
249
, ,
( ).
, ,
.. .
, Vim. ,
, ,
, .
system(),
.
.
,
.
,
,
.
Quick Fix
,
quickfix Vim.
.
.
.
.
, .
250
12. Vim
,
.
GUI
,
, x y .
Vim
() Vim.
.
,
, exists,
Vim, has, ,
.
,
, Vim.
. ,
, .
Vim. ,
: http://www.vim.org/scripts/index.php.
2000 .
.
.
, Vim.
, :
help
help
help
help
help
autocmd
scripts
variables
functions
usr_41.txt
Vim,
. ,
.vim, ,
.
. .
13
13.
Vim (gvim)
vi
(GUI).
Emacs vi,
, GUI
, vi .
vi
. Vim gvim.
vi, gvim
.
.
gvim
Vim, ,
.
(
!) GUI
, gvim .
,
,
.
.
gvim MS Windows ,
easy gvim ( gvim). , ,
Vim,
, easy.
, ,
252
. gvim
.
: MS Windows
X Window System. ,
,
. GUI .
gvim
gvim , , Vim,
. gvim
,
,
. , ,
vi, gvim
, vi .
gvim
Vim GUI,
gvim Vim
-g. Windows
,
: Windows Explorer
Edit with Vim. gvim,
Windows. ,
, .exe.
, :
.
gvim
Vim. gvim
: .vimrc, .gvimrc. gvim
.vimrc,
.gvimrc. gvim Vim.
, :set columns=100 Vim,
.
gvimrc ( $VIM/gvimrc),
. ,
, ,
. ,
.
Vim
.
gvim
( )
, , :
gvim
253
exrc, $GVIMINIT.
gvimrc, $HOME/.gvimrc.
, (sourced).
$HOME , Windows gvim $VIM/
_gvimrc. ( Windows,
, UNIX
$HOME.
UNIX Cygwin.)
, _gvimrc , gvim .gvimrc.
, ,
$MYGVIMRC
.
.
exrc:
set exrc
gvim .
Vim , gvim
:
, (:)
.
,
.
c mouse.
. ,
,
.
i mouse.
254
. ,
,
, ,
.
,
Vim.
, .
, ,
gvim .
gvim , ,
. ,
. gvim
;
.
!
,
, .
, .
n mouse.
,
. ,
. gvim
. ,
- (, ).
,
, ,
.
, ,
Vim. , ,
.
, gvim ,
.
v mouse. ,
,
.
, .
mouse .
:
:set mouse=""
.
gvim
255
:set mouse=a
( ).
:set mouse+=v
(v).
+=,
mouse.
:set mouse-=c
(c).
-=,
mouse.
, ,
( ) .
,
gvim :behave,
mswin xterm.
, mswin
Windows, xterm X Window System.
Vim , mousefocus, mousehide,
mousemodel selectmode. ,
Vim.
, gvim
,
mouse.
gvim ,
, Vim ,
. .
Windows gvim
Windows gvim
Vim ,
, .
, . 13.1,
.
.13.2.
gvim,
,
gvim, .13.3.
() , ,
.13.4.
256
.13.3.
gvim
.13.4. gvim
, .13.3
.
, .
, , ,
.
257
,
Vim.
Windows .
,
gvim GUI,
, .
, .
gvim
(.13.5).
.13.5. gvim
,
, .
guioptions,
GUI .269.
Vim
( ),
, gvim
.
/
/ r l guioptions. l
, , r
. L R
, .
/
b guioptions.
, ,
! , ,
.
. ,
,
.
258
, guioptions, ,
.
gvim , . ,
:set guioptions += -=,
. , :set guiopti
ons+=l gvim
guioptions .
gvim .
, . 13.5,
.
. 13.6 .
Global Settings Edit.
.13.6. Edit
259
,
Vim.
. .
, ,
,
Vim. , .13.6 ,
Undo Edit ,
,
u, .
. 13.6,
, .
, ,
.
Toggle Pattern High
light, .13.6, - .13.7.
.
.
. ,
(
) .
.
.13.7.
260
gvim $VIMRUNTIME/menu.vim.
.
map
.126, :
:map <F12> :set syntax=html<CR>
.
, html
F12 HTML
File. :amenu:
:amenu File.HTML :set syntax=html<CR>
<CR> ,
.
File. HTML,
.13.8. amenu menu ,
(,
).
menu
. .
261
, (.). File.HTML
HTML File. ,
.
, ,
.
. ,
, Vim XML,
.13.9. ,
Vim gvim (.
.232).
HTML Vim
, ,
HTML (.13.10).
.13.9. ,
XML
.13.10. , HTML
, HTML
. ,
.
-, :
:aunmenu File.HTML
,
menu, unmenu.
HTML,
, :
:amenu File.HTML<TAB>syntax=html<CR> :set syntax=html<CR>
262
, , <TAB> (
) syntax=html<CR>. ,
, <TAB>
<CR>. File
.13.11.
.13.11. HTML,
(
), (\),
Vim , ,
. ,
:set syntax=html
syntax=html, :amenu :
:amenu File.HTML<TAB>set\ syntax=html<CR> :set syntax=html<CR>
, .
,
, .
, MyMenu
HTML. HTML File:
:aunmenu File.HTML
:
:amenu MyMenu.HTML<TAB>syntax=html :set syntax=html<CR>
263
13.12 ,
.
.13.12. MyMenu
, ,
. .
.
,
gvim, .
,
MyMenu, gvim
Window Help. gvim
, , ,
. ,
, gvim.
,
.13.5 gvim,
.13.1.
13.1. , gvim
File
10
Edit
20
Tools
40
Syntax
50
Buffers
60
Window
70
Help
9999
, File ,
Help (- File Help),
Help .
, .
264
,
menu. ,
, 500. MyMenu
Window ( 70) Help ( 9999).
, File
Edit. MyMenu 10, 20.
15,
:
:15amenu MyMenu.HTML<TAB>syntax=html :set syntax=html<CR>
,
, . ,
, ,
, .
,
,
.
, ,
.
,
(9999) HTML,
File:
:amenu File.HTML .9999 <TAB>syntax=html<CR> :set syntax=html<CR>
9999? ,
: File,
HTML. File ,
.
,
.
, , . ,
, ,
EditGlobal SettingsContext linesDisplay,
(Display) 30,
...30. :
Edit.Global\ Settings.Context\ lines.Display ...30
,
.
,
gvim. ,
265
, ...
(-) 1.
, , .
gvim,
.gvimrc.
:
" add HTML menu between File and Edit menus
15amenu MyMenu.XML<TAB>syntax=xml :set syntax=xml<CR>
amenu .600 MyMenu.-Sep- :
amenu .650 MyMenu.HTML<TAB>syntax=html :set syntax=html<CR>
amenu .700 MyMenu.XHTML<TAB>syntax=xhtml :set syntax=xhtml<CR>
,
.
:
() 15, gvim , 15.
File Edit.
(, ) ,
,
.
(, ),
. ,
.600. ,
,
, , 500.
,
, .13.13.
.13.13.
266
. , Windows
gvim .
.13.2 .
13.2. gvim
Vim
make
,
, . :
:set toolbar="text,icons"
, Vim
,
,
. , gvim
: +GUI_GTK, +GUI_Athena, +GUI_
Motif +GUI_Photon. 9 ,
Vim gvim.
.
, :menu,
.
267
, gvim
, .
gvim .
,
,
, menu ,
. ,
.
.
:
:amenu icon=/some/icon/image.bmp ToolBar.NewToolBarSelection Action
/some/icon/image.bmp ,
( ),
, NewToolBarSelection
, Action , .
, ,
DOS Windows. ,
PATH Windows ( ),
DOS gvim,
(.. , Action):
:!cmd
,
$HOME/dos.bmp
DOS, .13.14.
.13.14. DOS
:
:amenu icon="c:$HOME/dos.bmp" ToolBar.DOSWindow :!cmd<CR>
. , . 13.15.
.
.13.15. DOS
268
gvim
, .
.
. , . 13.16 ,
Find Previous .
:tmenu ,
. :
:tmenu TopMenu.NextLevelMenu.MenuItem tool tip text
TopMenu.NextLevelMenu.MenuItem
,
. , Open File
:
:tmenu File.Open Open a file
ToolBar
(
).
DOS . :
:tmenu ToolBar.DOSWindow Open up a DOS window
, .13.17.
.13.17. DOS
269
Windows
, ,
, . Vim
Windows.
Copy Cut,
Vim Windows.
Windows.
X,
.
( ) X
(man).
GUI
. 13.3 ,
gvim. Vim,
GUI, , gvim
vim -g.
270
13.3. , gvim
guicursor
guifont
guifontset
guifontwide
guiheadroom
guioptions
guipty
:!
guitablabel
guitabtooltip
toolbar
-g
GUI (
)
-U gvimrc
GUI
gvimrc
:gui
GUI ( UNIX-
)
:gui filename...
GUI
:menu
:menu menupath
,
menupath
menupath,
action
menupath
n
271
GUI
:menu ToolBar.toolbarname
action
toolbarname,
action
menupath
text
:unmenu menupath
menupath
14
14.
Vim
Vim.
,
. -
, .
,
.
, , ,
, ..
(IDE)
, . IDE
(, Visual Studio)
(Eclipse),
,
.
.
,
, . , ,
,
IDE. , ,
, IDE ,
, .
Vim
IDE.
.
, IDE.
( )
273
,
. Vim ,
. ,
-IDE Quickfix,
. :
( )
Quickfix, -IDE Vim
( )
(fold) ,
. , ,
, .
.
(
). Vim
.
14.1 , Vim.
, .
.14.1. Vim
274
14. Vim
11 ,
10. , 15,
16 22. ,
26, 27 29.
. (
).
Vim
. , , Vim
, : :mkview :loadview.
1,
.
, , ,
.
.
,
,
, ,
.
Vim
, .
.
, ,
,
.
:
manual
Vim, .
indent
shiftwidth.
expr
.
syntax
(,
C ).
diff
.
1
Vim :mksession; . 15. . . .
( )
275
marker
(
) .
(, , )
.
Vim ,
, ,
, .
,
.
.
z.
( )
z.
20 , z.
, (
) ,
(/).
:
zA
, .
zC
, .
zD
, .
zE
.1
zf
,
.
countzF
, count , .
zM
foldlevel .
1
zD, ( )
, zE
. . . .
276
14. Vim
zN, zn
(zN) (zn) foldenable.
zO
, .
za
.
zc
.
zd
.
zi
foldenable.
zj, zk
(zj)
(zk) . ( j
(jump) k,
.)
zm, zr
(zm) (zr)
foldlevel.
zo
.
.
. ,
.
zA, zC, zD zO ,
, ,
.
Vim,
,
.
, :
3zF
2zfj
3zF zF ,
; 2zfj , j (
).
( )
277
C.
C,
({ }) zf% (, %
).
, zfgg (gg
).
. ,
, .
(cues) ,
Vim.
. 14.2,
() C.
.
.14.2. -
. -,
Vim .
( number),
, ,
,
. Vim ,
.
278
14. Vim
.
. ,
Vim .
, .14.2 18.
,
zf2j. .14.3 .
.14.3. , 18
, Vim
+-- ,
. , +.
.
,
if.
zf%. ,
.14.4.
.14.4. , if
,
. . ,
.
25
fcn
( )
279
. .
zf,
fcn, ?int fcn ( Vim),
ENTER. , .14.5.
.14.5.
,
(, 3zf),
. ,
30, 3135
( 36), 3zf
, ,
: 30, ,
3135, 36,
. ? . , zf
, .
. -,
zO ( z O, ).
, . 14.6.
foldcolumn.
(-),
(|). (
) ,
. , 525
( ), 15
22 (2), 1820 .
(
, ; ,
). :
:set foldcolumns=n
n ( 12,
0). foldcolumn=5 (
, foldcolumn
3. ).
280
14. Vim
.14.6.
.14.7. 1820
.
,
1820, zc (
). 14.7 .
? Vim
, .
,
. (18) ~~ (
). , Vim
281
( )
~ (
compatible), , ,
. ,
zo ( ). ,
.14.8.
.14.8. ,
. ,
.14.7 18 ,
18 20, dd ( )
.
, Vim
, ,
. ,
u () ,
.
, ,
.
foldcolumn. ,
. , zc ( )
, .
foldcolumn.
, , ,
, .
( ) ,
:
1. This is Headline ONE with NO indentation and
1.1 This is sub-headline ONE under headline
This is a paragraph under the headline.
level is 2.
1.2 This is sub-headline TWO under headline
NO fold level.
ONE
Its fold
ONE.
282
14. Vim
2. This is Headline TWO. No indentation, so no folds!
2.1 This is sub-headline ONE under headline TWO.
Like the indented paragraph above, this has fold level 2.
- Here is a bullet at fold level 3.
A paragraph at fold level 4.
- Here is the next bullet, again back at fold level 3.
And, another set of bullets:
- Bullet one.
- Bullet two.
2.2 This is heading TWO under Headline TWO.
3. This is Headline THREE.
Vim
(outline). indent:
:set foldmethod=indent
shiftwidth ( )
4.
. shiftwidth (
)
1. ,
, shiftwidth . ,
1. (
shiftwidth) 2 ..
fold
level. ,
,
.
:
:set foldlevel=0
, .14.9.
,
, foldlevel, 2.
2 , .14.10.
,
(zr) (zm).
( )
283
,
(syntax) .
C, Vim ,
C.
,
.
-, zE ( ) ,
.
().
:set foldenable
, (
, foldenable
foldmethod, manual). :
:set foldmethod=syntax
, .14.11.
Vim ,
C. zo 6
, Vim .
284
14. Vim
. (?)
Vim .
diff Vim ( vimdiff)
, ,
. .14.12,
( ).
Vim
.
vi autoindent,
.
,
:set:
:set cindent
Vim ,
:
autoindent
, autoindent vi.
.
smartindent
, autoindent,
C .
cindent
, cindent
C ,
. , cindent
, ( )
285
, ( )
({}), ,
.
indentexpr
, Vim
.
, .
,
Vim.
, indentexpr, ,
.
autoindent Vim vi
Vim autoindent vi,
, compatible.
Vim
,
.
wrapmargin ( ,
, wrapmargin),
textwidth ( ,
textwidth). .14.3 Vim vi
.
, ( 16 )
. ,
compatible ( vi), textwidth
286
14. Vim
,
wrapmargin.
smartindent
smartindent autoindent.
, C
, cindent.
smartindent , :
, .
,
cinwords.
,
(}), ,
,
O ( ).
( ) (}).
cindent
, Vim,
, cindent indentexpr. indentexpr
, ,
cindent.
(
). cindent
, ,
.
indentexpr , cindent.
cindent :
cinkeys
, Vim
.
cinoptions
.
cinwords
, Vim
.
cindent , cinkeys, ,
. cinkeys ,
.
287
cinkeys
cinkeys , :
0{,0},0),:,0#,!^X^F,o,O,e
, ,
:
0{
0 ()
, {. { , Vim
.
, ,
,
C. ,
, .
{ :
.
:
main ()
{
if ( argv[0] == (char *)NULL )
{ ...
0}, 0)
,
. } ),
Vim .
} ,
{.
) shiftwidth.
:
C case statement. : ()
case statement, Vim
.
: 1
. ,
, .
1,
.
0#
.
#, Vim .
,
.
(#define...) .
288
14. Vim
!^F
.
- ^F ( CTRL-F),
CTRL-F Vim
.
o
ENTER ,
o ( ).
O
O ( ).
e
else. else, Vim
. ,
e else.
cinkeys. cinkeys
(!, * 0) ,
. :
!
( CTRL-F), Vim
.
( +=),
. ,
, .
, !, .
*
Vim ,
.
0
. ,
0, ,
.
Vim vi
. , ^
,
( ); I.
0
, .
289
cinkeys
, ,
.
:
<>
.
. , <:>
:. ,
<Up>.
^
(^) .
, ^F CTRL-F.
o, O, e, :
cinkeys
.
=word, =~word
,
. ,
, word, Vim .
=~word =word, .
, (word) .
, word ,
,
. Vim end,
end, endif.
cinwords
cinwords , , ,
.
:
if,else,while,do,for,switch
C.
. Vim
ignorecase.
,
cinwords .
290
14. Vim
cinoptions
cinoptions Vim
C.
, :
,
.
,
.
.
cinoptions 28 :
s,e0,n0,f0,{0,}0,^0,:s,=s,l0,b0,gs,hs,ps,ts,is,+s,c3,C0,/0,(2s,us,U0,w0,W0,
m0,j0,)20,*30
Vim. cinopti
ons .
, (
)
.
, ,
. ,
, .
, cinoptions=f5 ,
({) ,
.
(
) shiftwidth.
w ( cinoptions=f5w),
shiftwidth.
(
) (-) .
cinoptions
. , =
. cinoptions
, : +=
, -= ,
-=, +=.
, , ,
. cinoptions.
( )
.
291
>n ( s)
n .
s,
shiftwidth.
fn, {n
f ,
({). ,
.
, , while,
w while.
{ f,
.
.
.14.14 14.15 Vim,
cinoptions=s,f0,{0, cinoptions=s,fs,{s.
shiftwidth 4 ( ).
.14.14. cinoptions=s,f0,{0
.14.15. cinoptions=s,fs,{s
}n
,
(})
. (
).
^n
n ({}),
.
292
14. Vim
:n, =n, bn
case.
: Vim n
switch.
shiftwidth.
=
. shiftwidth.
b break.
() break
case. break
.
)n, *n
Vim ,
(20
) ( 30 ),
.
, ,
Vim .
,
. 40
60 .
indentexpr
, indentexpr cindent,
.
indentexpr ,
. ,
Vim .
, indentkeys
cinkeys, ,
.
,
. , , ,
. $VIMRUNTIME/indent ,
.
70 .
,
ada, awk, docbook ( docbk), eiffel, fortran, html,
java, lisp, pascal, perl, php, python, ruby, scheme, sh, sql zsh.
, xinetd!
293
Vim
, .vimrc filetype
indent on.
. ,
, ,
:filetype indent off.
, Vim.
,
vim.org. ,
Vim.
, ,
:
,
, Vim ,
.
Vim
.
.
, .
.
, Vim pas
te.
, .
paste :set nopaste.
Vim
. ,
,
, . , Vim
, ,
,
!
294
14. Vim
,
.
:
dictionary
thesaurus
( ctags)
Vim
Omni
complete
, CTRL-X.
,
. , CTRL-X CTRL-F
( , ). Vim
,
,
(,
CTRL-X CTRL-N CTRL-N).
, :
. ,
, CTRL-X CTRL-F,
, CTRL-F,
. , CTRL-N ( next),
, CTRL-P ( previous)
.
,
, .
,
, ,
.
.
295
,
. Tab:
:imap Tab <C-P>
,
,
( ) (DOS
xterm, konsole ..)
. ( , ,
CTRL-V.)
Tab
Vim.
CTRL-X CTRL-L.
, .
, , .
, ()
, .
.14.16.
.14.16.
, This terminal
widely used in our company.... ,
(widely used)
.
, ,
CTRL-X CTRL-L. .14.17 :
# Thi
296
14. Vim
. ,
, .
complete
.
.
(CTRL-N) (CTRL-P)
1 .
ENTER 2.
, CTRL-E,
, .
.
.14.19
.
.14.17. ,
gvim; Vim -.
Vim (7.3) ,
(, , ..). .
. .
297
CTRL-X CTRL-N ,
, .
CTRL-N CTRL-P
. ENTER,
.
,
. ,
, .
iskeyword.
,
,
. iskeyword
(, a-z) ASCII (,
az 97-122).
,
, . C-
,
.
CTRL-X CTRL-K ,
, dictionary.
dictionary .
,
.
:
/usr/dict/words (Cygwin XP)
/usr/share/dict/words (FreeBSD)
$HOME/.mydict ( )
, Windows XP
Cygwin (http://www.cygwin.com/) ,
UNIX. Cygwin
, ,
Cygwin ( ,
).
CTRL-X CTRL-T ,
, thesaurus.
. Vim
(
), Vim .
298
14. Vim
( ),
, .
, :
fun enjoyable desirable
funny hilarious lol rotfl lmao
retrieve getchar getcwd getdirentries getenv getgrent ...
(
fun funny),
C,
, get.
retrieve.
C,
Vim .
fun, CTRL-X CTRL-T. 14.20
, gvim.
:
Vim ,
, .
- ,
. ,
fun, funny.
, ,
,
. ,
:
funny hilarious lol rotfl lmao
hilar , Vim
, hilarious , hilarious, lol,
rotfl lmao. !
? completeopt preview,
, Vim .
,
retrie. retrieve
, get
- . CTRL-X
CTRL-T ( gvim),
. . .14.21.
,
ENTER.
299
.14.20. fun
.14.21. retrie
CTRL-X CTRL-I ,
(include) .
(CTRL-X CTRL-P) , Vim
.
Vim include ,
. ,
,
C:
# include <somefile.h>
300
14. Vim
Vim somefile.h
.
path .
CTRL-X CTRL-] ,
(
.147).
CTRL-X CTRL-F ,
. , Vim
, .
Vim 7.1
.
Vim,
path. ,
, path 1.
CTRL-X CTRL-D
, #define.
.
Vim
, CTRL-X CTRL-V,
Vim
.
Vim.
CTRL-X CTRL-U
. Vim
, completefunc.
Vim 12.
omni-2
, CTRL-X CTRL-O,
, .
1
Vim 7.3. . . .
IDE
: , .. . . .
301
, ,
, ,
. omni-
C, CSS, HTML, JavaScript, PHP, Python, Ruby, SQL XML.
Vim ,
Vim7.1 ,
omni C++. .
CTRL-X CTRL-S.
, Vim .
,
.
complete
, CTRL-N
.
,
.
complete , .
,
. .
:
. ()
.
w
( ,
Vim).
b
(
Vim).
u
.
U
, .
k
( dictionary).
kspell
(
, ).
s
( thesaurus).
302
14. Vim
i
.
d
, .
t, ]
.
Vim
, ,
. ,
.
,
.
. (
UNIX, )
,
CTRL. ,
.
,
. ,
Tab.
DocBook ( grep
) emphasis 1200 !
, emph
emphasis. ,
(,
). ,
, 3600 !
: ,
. ,
3600/4,
15 . DocBook
20 30 .
!
.157.
, ,
.
. ex Vim
.14.1.
303
14.1. Vim
ta[g][!] [tagstring]
, tagstring,
. ! Vim
, ,
.
autowrite.
[count]ta[g][!]
count- .
[count]po[p][!]
,
. count,
count- .
tags
:tselect,
.
[count]tn[ext][!]
count-
( ).
[count]tp[revious][!]
count-
( ).
[count]tN[ext][!]
[count]tr[ewind][!]
.
count, count- .
tl[ast][!]
, Vim ,
. :
tag 1 of >3
(>) ,
. :tnext :tlast .
- -
, :0tn, .
:tags,
(>):
#
1
> 2
3
in file
harddisk2:text/vim/test
-currentharddisk2:text/vim/src/amiga.c
:tselect
. ( pri)
(, ; ,
; ..). Vim.
304
14. Vim
nr pri kind tag
file ~
1 F f
mch_delay
os_amiga.c
mch_delay(msec, ignoreinput)
> 2 F f
mch_delay
os_msdos.c
mch_delay(msec, ignoreinput)
3 F f
mch_delay
os_unix.c
mch_delay(msec, ignoreinput)
Enter nr of choice (<CR> to abort):
:tag :tselect ,
/. ,
Vim ,
. , :tag /normal NORMAL, normal_cmd
.. :tselect /normal .
vi .14.2.
, Vim
.
14.2. Vim
^]
.
g <LeftMouse>
CTRL-<LeftMouse> .
^T
,
.
, .
Vim, , .14.3.
14.3. Vim
taglength, tl ,
. , ,
, .
tags
,
. , ./,
,
. : "./tags,tags".
tagrelative
true ( )
,
,
.
305
, Vim , ,
.
Vim vi. Vim
,
- . :
, .
Vim , ,
,
.
Vim
, ,
,
. , ,
, .
.
:
:syntax enable
,
, ,
,
. , syn
tax :
:syntax on
enable ,
,
.
, , , Vim
, ,
. .
,
,
Vim , ,
, . ,
.sh.
. ,
306
14. Vim
, Vim , ,
.
( ), Vim
. ,
,
- . ,
,
.
Vim
, . ,
,
:
:set syntax=sh
.236 .
Vim ,
. , ,
Vim ,
.
$VIMRUNTIME/syntax.
,
, Vim 500 .
(C, Java, HTML) (calendar)
(fstab, xinetd, crontab). Vim
, $VIMRUNTIME/syntax
, .
, ,
.
. Vim
.
,
(,
, ),
.
, :
, , .
, .
307
,
. , colorscheme highlight,
, background, ,
.
,
.
, .
Vim .
. ,
.
. ,
, , ,
.
:
Comment ()
, :
// I am both a C++ and a JavaScript comment
Constant ()
, TRUE.
Identifier ()
.
Type ()
, int struct C.
Special ()
, .
,
:
SpecialChar ( ).
Tag ().
Delimiter ().
SpecialComment ( ).
Debug ().
,
,
.
308
14. Vim
colorscheme
, , ,
. Vim
:
blue
darkblue
default
delek
desert
elflord
evening
koehler
morning
murphy
pablo
peachpuff
ron
shine
slate
torte
zellner
$VIMRUNTIME/colors.
:
:colorscheme schemeName
Vim
: :color,
Tab ,
, Tab
.
gvim . Edit,
Colorscheme (
). ,
.
background
Vim
. :
.
-. ,
, (
309
). Vim
, ,
. ,
- .
,
background. :
:set background?
, , .
:
:set background=dark
background colorscheme
.
, .
highlight
highlight Vim
. .
,
. :
:highlight comment
.14.22.
.14.22.
. xxx
-, . term=bold ,
- .
ctermfg=4 , , xterm
,
DOS dark blue. , guifg=Blue ,
.
DOS ,
. DOS : black, red,
green, yellow, blue, magenta, cyan white.
()
bright . Vim
, xterm.
310
14. Vim
. Vim
, Blue,
, . #rrggbb, #
, rr, gg bb ,
. ,
#ff0000.
highlight ,
. , ,
GUI -
, .14.23.
:highlight identifier
:
:highlight identifiers guifg=red
( ).
:
.
.14.23.
,
, highlight:
:highlight
14.24
highlight.
.14.24. highlight
311
,
( term, ctermfg ..),
(, String Cons
tant).
,
. ,
. Vim after.
, Vim
.
, (
)
after,
runtimepath. , Vim
,
after.
, XML,
xml. , Vim
xml.vim syntax. ,
, .
xml.vim ~/.vim/after/syntax
:
highlight identifier ctermfg=red guifg=red
, ~/.vim/after/syntax
runtimepath:
:set runtimepath+=~/.vim/after/syntax
.vimrc
,
.vimrc.
Vim, xml,
, .
,
,
.
.
.
, -
, ,
.
312
14. Vim
loremipsum.
latin:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin eget
tellus. Suspendisse ac magna at elit pulvinar aliquam. Pellentesque
iaculis augue sit amet massa. Aliquam erat volutpat. Donec et dui at
massa aliquet molestie. Ut vel augue id tellus hendrerit porta. Quisque
condimentum tempor arcu. Aenean pretium suscipit felis. Curabitur semper
eleifend lectus. Praesent vitae sapien. Ut ornare tempus mauris. Quisque
ornare sapien congue tortor.
In dui. Nam adipiscing ligula at lorem. Vestibulum gravida ipsum iaculis
justo. Integer a ipsum ac est cursus gravida. Etiam eu turpis. Nam laoreet
ligula mollis diam. In aliquam semper nisi. Nunc tristique tellus eu
erat. Ut purus. Nulla venenatis pede ac erat.
...
, latin. Vim latin.
vim
$HOME/.vim. ,
syntax keyword.
lorem, dolor, nulla lectus,
:
syntax keyword identifier lorem dolor nulla lectus
loremipsum.latin
. ,
. :
:set syntax=latin
$HOME/.vim ,
runtimepath, , .14.25.
, ,
-, . ,
( ,
).
.14.25.
313
.14.26.
, , Lorem .
.
:
:syntax case ignore
, Lorem .
,
. Vim
( )
ftdetect runtimepath.
, $HOME/.vim latin.vim,
:
au BufRead,BufNewFile *.latin set filetype=latin
Vim, .latin
, , Vim
$HOME/.vim/syntax/latin.vim .
loremipsum.latin .14.26.
-, , ,
Vim latin.
.
, match
Comment.
. , ,
s t,
Comment (, !).
: \<s[^\t ]*t\> ( ).
Number.
start end.
Suspendisse sapien\..
. lectus
. latin.vim :
314
14. Vim
syntax
syntax
syntax
syntax
syntax
case ignore
keyword identifier lorem dolor nulla lectus
keyword identifier lectus contained
match comment /\<s[^\t ]*t\>/
region number start=/Suspendisse/ end=/sapien\./ contains=identifier
loremipsum.latin ,
.14.27.
, ,
:
. sit
,
match.
. ,
Suspendisse sapien., (!).
, .
lectus
, identifier
contained, contains identifier.
. ,
,
.
.14.27.
Vim
Vim (IDE),
,
.
,
.
: -- ,
Vim
315
Vim, ,
, .
Vim Quickfix List.
, Vim
make .
,
.
Quickfix List,
, .
C,
.
:
# include <stdio.h>
int main(int argc, char *argv[])
{
/*
* arg 1: starting value
* arg 2: second value
* arg 3: number of entries to print
*
*/
if (argc
{
printf
printf
return
}
- 1 != 3)
("Three command line args: (you used %d)\n", argc);
("usage: value 1, value 2, number of entries\n");
(1);
316
14. Vim
for (index=1; index<=count; index++)
{
current = nMinusTwo + nMinusOne;
printf("%d %04d ratio (golden?) %.3f\n",
index,
current,
(double) current/nMinusOne);
nMinusTwo = nMinusOne;
nMinusOne = current;
}
}
Vim (, fibo
nacci.c) :
:make fibonacci
make
Quickfix List.
Quickfix List
.14.28.
,
.
:
long int current, nMinusOne, nMinusTwo;
:
longish int current, nMinusOne, nMinusTwo;
:
nMinusTwo = first;
nMinusOne = second;
xfirst xsecond:
nMinusTwo = xfirst;
nMinusOne = xsecond;
:
printf("%d %04d ratio (golden?) %.3f\n", 2, second, (float) second/first);
:
printf("%d %04d ratio (golden?) %.3f\n", 2 second (float) second/first);
. .14.29
Quickfix List.
1 Quickfix List
. ,
. , 3
.
Vim
317
318
14. Vim
--, ,
.
Vim
, ,
. ,
, ,
Vim,
, :
makeprg
, make compile
.
:cnext, :cprevious
,
, Quickfix List, .
:colder, :cnewer
Vim 10 .
Quickfix List
.
n n- .
errorformat
, , Vim
.
,
, .
,
:
:help errorformat
Quickfix List
Vim ,
grep. Quickfix List
, ,
.
, .
DocBook,
XML. -
vim <emphasis> <literal>. , :
<emphasis>vim</emphasis>
:
<literal>vim</literal>
319
:
:vimgrep /<emphasis>vim<\/emphasis>/ *.xml
.
,
:
:%s/<emphasis>vim<\/emphasis>/<literal>vim<\/literal>/g
, vimgrep
. vimgrep,
. Vim
.
.
,
. vi
, .
Vim .
, ,
Vim .
Vim .
,
Vim. !
15
15.
Vim
10 14 Vim ,
, ,
. 15 Vim.
,
, Vim,
(,
!).
vi, Vim .
, .
?
, ?
, ?
Vim,
, . ,
,
.
,
. ,
.
321
. ,
JPEG .
, ( ),
( ,
). JPEG
- (, ,
, ) ,
.
Vim
(year) JPEG
.
.15.1 JPEG.
, . ,
.
.15.1. JPEG
,
, Vim
,
.
.
Vim binary:
set binary
Vim -b.
Vim, :
textwidth wrapmargin 0.
.
modeline expandtab (nomodeline noexpandtab).
shiftwidth
322
15. Vim
modeline1,
,
.
. Vim
.
, .
: -ASCII
, George Frideric Hndel (
), George Frideric Handel? , rsum
, resume? Vim
.
, .
.
Vim ,
.
(CTRL-K) BS (Back
space) . (
,
,
.
.)
,
, ph di
graph phonetic. Vim
, , ,
.
, .
, Vim . ,
.
,
CTRL-K, ,
,
, (
..). . . .
: -ASCII
323
, . ,
c (), CTRL-K c,. a ()
CTRL-K a!.
,
(, CTRL-K p*
).
, 1 ,
, . CTRL-K ?I (, I
) () CTRL-K ss,
().
Vim, digraph:
set digraph
,
, backspace (BS),
, . , cBS,, aBS!.
digraph
CTRL-K. CTRL-K ,
. ,
- Backspace
.
:digraph,
; :help di
graph-table. 15.2
digraph.
.15.2. Vim
, ,
. . . .
324
15. Vim
digraph .
, Vim
, .
, ,
Unicode .
.15.1 ,
,
.
15.1.
(fianc)
(publica)
(Dubcek)
(franais)
(portugus)
(voil)
(%tm%)
(Sren)
(seor)
(Nol)
(')
(
(<)
(,)
(>)
(!)
(-)
(/)
(?)
(:)
Vim
,
! URL
, Vim
(, ). ,
.vimrc, ehannah
mozart.
SSH 122 ( ,
- ):
$ vim scp://ehannah@mozart:122//home/ehannah/.vimrc
ehannah
, URL,
.
:
$ vim scp://ehannah@mozart:122/.vimrc
URL URL
:
325
scp:
, , .
scp ,
SSH (Secure Shell).
(:) .
//
,
[user@]hostname[:port].
ehannah@
. ,
scp, ,
. ,
.
.
mozart
,
, 192.168.1.106.
:122
,
.
.
, URL .
122
scp. , mozart
122, .
//home/ehannah/.vimrc
,
. ,
.
,
.
, . ,
ehannah, /home/ehannah.
:
ftp: sftp: ( FTP FTP).
scp: ( SSH).
http: ( ).
dav: ( ,
).
rcp: ( ).
326
15. Vim
, ,
. -
. ,
,
.
, ,
.
.
Vim, , , ,
, .
ex-050325, .c (
vi). ex-050325 :
$ vim ex-050325
. 15.3 ,
, .
Vim : (
), (
) . .
,
Vim (, w
, j ..)
.
:
, ENTER
.
, ENTER
.
, o . Vim
,
( :
, Vim ,
, ).
327
.15.4.
.
R. ,
, Vim
, .
.15.4.
.
:
D. Vim
. ,
.
.
expreserve.c
ex-050325. ,
:
/expreserve.c
ENTER o.
328
15. Vim
- ,
, Vim
,
.
, ,
.
Vim
Vim ,
.
,
.
: backup write
backup.
: backupskip, backupcopy, backupdir backupext.
backup writebackup ( noback
up nowritebackup), Vim
. backup ,
. backup
, writebackup, Vim
.
Backupdir ,
Vim . , ,
, back
updir "C:\TEMP" Windows "/tmp" UNIX Linux.
,
,
. (). ,
, ,
. , backupdir
- "./.mybackups,." (
). ,
.
, backupskip,
, . Vim
, . ,
,
/tmp /var/tmp.
"/tmp/*,/var/tmp/*" backupskip.
HTML
329
Vim ,
~ () . ,
.
backupext .
, , .bu,
backupext ".bu".
, backupcopy , .
"auto", Vim
.
HTML
? - ,
Vim, ?
HTML .
Vim HTML .
,
, .html. Vim
HTML- .
gvim Convert to HTML
,
gvim ( 13). gvim
Syntax Convert to HTML.
2html.vim,
, Convert to HTML,
. :
:runtime!syntax/2html.vim
: .
TOhtml,
2html.vim,
,
. , 25 44
, :
:25,44TOhtml
gvim HTML
, GUI
HTML. ,
.
330
15. Vim
, . Vim
, .
HTML- . ,
HTML .
HTML .
. :
Open File File,
, HTML-.
,
.
?
,
. UNIX diff Vim
,
vimdiff.
:
Vim:
$ vimdiff old_file new_file
$ vim -d old_file new_file
,
, , . ,
.
.15.5 vimdiff. -
wrap,
.
(, - ),
:
4 ,
. , .
32 ,
.
11 Vim 15- .
15 . Vim ,
.
331
4142 ,
(-), ,
. ,
.
-
.
vimdiff Vim UNIX-,
diff UNIX.
UNIX diff. Vim
diff ,
diff.
diffexpr ,
, vimdiff
. ,
:
v:fname_in
.
v:fname_new
.
v:fname_out
diff.
.15.5. vimdiff
332
15. Vim
Vim
, .
, ,
. undolevels
,
. 1000. ,
.
vi, undolevels 0.
:set undolevels=0
, vi u
.
,
. Vim , ,
, -.
Vim
, undolevels.
u ,
. Vim
:redo CTRL-R.
CTRL-R ,
.
(CTRL-R) (u) Vim
, .
, ,
! (
). ,
,
.
. .
, ?
, . , ,
, , ,
Vim.
,
.
,
.
333
Vim:
:help usr_32.txt
?
1, 1.
,
. ,
, ,
. Vim
.
: viminfo mksession.
viminfo
Vim viminfo, , ,
.
, Vim,
. viminfo
:
<n
Vim ,
n .
, .
,
. ,
10000 , (,
,
), , 10000
viminfo.
, viminfo .
Vim, , ,
viminfo .
- ,
. 50.
/n
.
, Vim history.
334
15. Vim
:n
. , Vim
history.
'n
, Vim
. viminfo,
.
viminfo :
1
( ,
mx,
'x)
.
, ,
,
. ,
n .
mksession
mksession Vim ,
. sessionoptions
,
.
, , viminfo.
, , , mksession
,
,
. viminfo,
.
, :
:mksession [filename]
, input();
-. . . .
335
filename ,
. Vim ,
source (
, Session.vim).
, :
:mksession mysession.vim
, :
:source mysession.vim
,
sessionoptions:
blank
.
buffers
.
curdir
.
folds
/ ,
.
,
. , ,
!
globals
,
.
help
.
localoptions
, .
options
, :set.
resize
Vim.
sesdir
, .
slash
, .
336
15. Vim
tabpages
.
sessionoptions,
.
.
unix
UNIX.
winpos
Vim .
winsize
.
, ,
, , ,
, sessionoptions
:
:set sessionoptions=buffers,folds,globals,options,resize,winpos
?
Vim .
,
,
, .
,
, wrap:
set nowrap
nowrap Vim ,
. ,
, . ,
100 20 ,
, 80 . ,
, Vim ,
100- . ,
5- , 14
, . 584
, , 85 100,
, .
Vim
. , Vim
, sidescroll.
:
337
set sidescroll=n
n .
sidescroll 1,
,
.
,
.
sidescroll . ,
Vim ,
. , w
.
Vim .
(),
, .
w ,
,
.
sidescrolloff.
,
. , sidescrolloff 10, Vim
10 ,
. ,
, ,
( ) 10 ,
. ,
Vim nowrap.
listchar.
list. Vim ,
, ,
. :
set listchars=extends:>
set listchars+=precedes:<
Vim < 1,
, >
,
. .15.6.
.15.6. nowrap
338
15. Vim
, ,
wrap Vim.
set wrap
, .15.7.
.15.7. wrap
, ,
@ ,
, .
.15.7 , .15.8,
.
.15.8.
Vim
Vim ,
. (
, ) .
, ,
!
.
Vim,
.
, UNIX,
.
:
n
prev
q
se
w
next
previous
quit
set
write
( Vim)
339
:
ai
bg
ff
ft
ic
li
nu
sc
sm
sw
wm
autoindent
background
fileformat
filetype
ignorecase
list
number
showcommand ( showcase)
showmatch
shiftwidth
wrapmargin
,
.
.vimrc .gvimrc , ,
,
, .. .
,
Vim (syntax, autoindent, colorscheme ..)
, .
.
( Vim)
. ,
vi, Vim,
:
,
.
xp ( , ).
, ?
ddp ( ,
).
Vim. F1
.
?
Vim
.
340
15. Vim
,
. ,
Vim ,
ENTER.
,
Vim .
CTRL-F .
( 7),
Vim.
, Vim,
.
,
ENTER. ,
.
:help sure
, Vim.
HTML-
Vim Vim:
Vim 6.2
http://www.vim.org/htmldoc/help.html
Vim 7
http://vimdoc.sourceforge.net/htmldoc/usr_toc.html
, http://vimdoc.sourceforge.net/vimfaq.html FAQ (
) Vim. ,
.
.
Vim
, -
wiki, .
wiki: http://vim.wikia.com/wiki/Category:Integration.
III
III.
vi
III vi,
Vim. :
16 nvi: vi
17 elvis
18 vile: vi Like Emacs
16
16.
nvi: vi
vi UCB 1970-
(Bill Joy), ,
- Sun Microsystems.
vi (Bill Joy) ex,
ed.
,
(Chuck Haley). 1976 1979 ex vi.
(Mark Horton),
1 ,
UNIX-
. 4.1 BSD (1981) ,
I .
, vi () UNIX ed. - .
1990- , 4.4 BSD,
BSD vi,
.
vi. , ,
.
344
16. nvi: vi
BSD nvi ex, vi view.
, nvi
, ,
. Q vi ex.
view vi,
readonly.
nvi .
:
-c command
command. POSIX-
+command, nvi
( ).
-F
.
,
, -
.
-r
,
, ,
.
-R
readonly.
-s
() . ex
.
1
elvis - .
345
, . POSIX-
-; nvi .
-S
secure,
1.
-t tag
tag.
-w size
size .
-
nvi .
troff, ASCII PostScript
:
vi
nvi,
nvi, , ex.
Man- vi
(manpage) nvi.
vi
vi.
ex
ex
nvi.
, ACSII,
nvi,
,
- vi.
nvi -
: :exusage :viusage.
ex vi. , ,
,
nvi.
:exusage :viusage .
nvi
, secure (),
. (Keith Bostic) ,
secure nvi .
346
16. nvi: vi
, , ,
.
-s -, nvi .
:
1. /etc/vi.exrc.
, root.
2. NEXINIT ,
EXINIT, .
. 1
$HOME/.nexrc $HOME/.exrc.
3. $HOME/.nexrc,
. $HOME/.exrc.
.
4. exrc,
./.nexrc, , ./.exrc.
.
nvi , -
.
nvi
( UNIX vi) .exrc
:source .exrc .nexrc
, nvi.
nvi,
ex, : Edit, Fg, Next, Pre
vious, Tag Visual ( ,
). ,
, .
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
1
NEXINIT EXINIT . . . .
347
, nvi : ch00.sgm
Makefile. nvi ch00.sgm
:Edit Makefile.
,
.
.
ex .16.1.
16.1. nvi
bg
.
fg Fg.
, ,
.
di[splay]
b[uffers]
di[splay]
s[creens]
, .
Next
, . /tmp
.
filename .
.
filename .
,
.
.
(nvi previous,
, vi ).
resize nrows nrows
.
Tag tagstring , tagstring, .
Previous
348
16. nvi: vi
CTRL-W , .
:q ZZ .
, .
, , , ,
nvi, ,
ESC.
,
.
nvi (GUI).
, .152.
, nvi.
POSIX, [[:alnum:]] .
:set extended:
|
.
.
(...)
,
.
extended, ,
, , \(...\) vi.
\1, \2 .. \(
.
+
.
, .
?
.
{...}
.
. n m
.
349
{n}
n
.
{n,}
n
.
{n,m}
n m.
extended , nvi
, \{ \}.
, extended ,
.
nvi,
.
nvi ex
.
cedit, .
nvi ,
. - ENTER,
. ESC (
^V ^[).
ENTER ,
j .
. filec.
nvi
,
* ,
.
ESC ( ^V ^[).
,
cedit,
350
16. nvi: vi
, cedit
.
nvi , TAB
filec. ,
:set filec=\TAB. ESC
.
.nexrc:
set cedit=^[
set filec=^[
.157.
nvi
. .16.2 16.3 .
16.2. nvi
di[splay] t[ags]
.
.
16.3. nvi
^]
tags ,
, .
.
^T
,
.
tags , nvi
.
351
, vi (.)
: ,
, .
nvi redo,
, u ( ).
, , u.
nvi ,
.
.
. (
1
, cscope Vim. .
. .
352
16. nvi: vi
). u, ,
.
, nvi u .
.
nvi
.
.
ex.
8- ^X,
.
nvi :set searchincr.
, .
-
nvi - :set leftright.
sidescroll , nvi
.
nvi .
nvi ,
.
,
:
nvi
,
(message catalog). nvi
, ,
catalog/README nvi.
(message catalogs) ,
, , , ,
.
353
, vi
26 . nvi
.
/tmp
ex, ,
/tmp nvi
.
nvi http://www.bostic.com/vi. -
1
.
.
LICENSE
.
nvi UNIX.
LynxOS 2.4.0 , , .
POSIX- ,
.
nvi .
ftp, , configure,
make:
$ gzip -d < nvi.tar.gz | tar -xvpf ...
$ cd nvi-1.79; ./configure
...
$ make
...
nvi .
make install.
nvi,
(Keith Bostic) bostic@bostic.com.
nvi ;
, - .
17
17.
elvis
:
elvis 1.0 vi
stevie, - . stevie
, Minix.
,
. ,
.
elvis 2.x 1.x. vi,
vi Minix.
. ,
1.x.
-, HTML.
elvis, ,
,
1! ,
vi vi.
! ..
355
elvis vi,
. ex, ,
Q vi ex.
elvis .
:
-a
,
.
-c command
command
POSIX- +command (
).
-f filename
filename
. .
-G gui
.
termcap. x11, windows, curses,
open quit. elvis
.
-i
, . ,
.
-o logfile
stdout/stderr.
MS Windows,
,
,
WinElvis . -o file
name
.
-r
.
-R
.
-s
ex (
POSIX). .
356
17. elvis
-S
security=safer ,
.exrc.
, .
-SS
security=restricted,
, security=safer.
-t tag
tag.
-V
.
.
-?
.
-
elvis . -
HTML .
-. HTML (
),
elvis.
HTML
(^] ^T),
.
.
, elvis (manpages)
UNIX.
elvis
, .
, elvis Common
Open System Environment (COSE).
.
.
, ,
.
357
1. (hardcoded) .
, elvis .
.
, , X11 termcap,
, X Window System
.
, .
2. , (
).
3. elvispath ELVIS
PATH, .
"~/.elvislib:/usr/local/lib/elvis",
.
4. elvispath ex elvis.ini
. elvis.ini
:
(
ASCII ).
, (
, ex, vi).
,
X11 .
: .exrc UNIX,
elvis.rc -UNIX . f.
EXINIT,
. :source ~/f, f ,
.
exrc, safely source
f .
X11 ,
, .
5. - , . elvis.msg.
.
6. , .
7. -a, ,
.
358
17. elvis
elvis :split.
ex,
:e filename :n. .
.
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
elvis ch00.sgm,
:split Makefile.
nvi, elvis .
,
,
. ex
.
17.1 ex
.
17.1. elvis
sp[lit] [file]
file,
. .
new
sne[w]
, ,
.
359
sn[ext] [file...]
,
. .
sN[ext]
,
. .
sre[wind][!]
,
. ( :next)
.
( ) .
sl[ast]
,
. .
sta[g][!] tag
,
tag.
sa[ll]
,
, .
wi[ndow] [target] , .
target .17.2.
close
. ,
. ,
elvis ,
.
wquit
.
, .
qall
:q .
.
17.2 ex
.
elvis
vi. .17.3.
17.2. window
, ^W k.
++
a , ^W^W.
, ^W j.
.
-num
buffer-name
a
, windowid=num.
, .
, . .
. .
360
17. elvis
17.3. elvis vi
^W c
.
:close.
^W d
(html, man, tex).
- .
.
.376.
^W j
^W k
^W n
,
. :snew.
^W q
, ZZ.
^W s
. :split.
^W S
wrap. ,
.
.
- .370.
^W ]
, .
:stag.
[count] ^W ^W
count- .
^W +
(
termcap).
^W -
(
termcap).
^W \
(
termcap).
, .
X11 elvis
.
.
. - Courier.
X11 elvis ,
,
( ),
, , ,
( ),
361
.
,
. ,
, , -client.
GUI MS Windows
XPM,
.
elvis .17.1.
elvis ,
.17.2. Motif,
.
, elvis: , ,
, ,
.
,
.
.17.1. elvis
362
17. elvis
.17.2. elvis
-client ,
elvis ,
. ,
elvis .
,
.
xterm
. , elvis
.
. 1
, 2 , 3
. ( 1, 2 3 -
, .
.) elvis v, ^V V
( ).
,
X11, ,
xterm. ,
.
1
. 3
.
.
2 X11 (, xterm).
ex,
, .
,
. , , elvis
.
363
1 ^],
, . elvis
HTML-,
, ,
. 3
^T,
.
X11
. , ~/.exrc
set notoolbar.
. :gui.
. ,
, ,
. :
:gui
:gui
:gui
:gui
Make:make
Make " Rebuild the program
Quit:q
Quit?!modified
.
Make, :make
( ).
Make,
. "
, :gui.
, Quit, .
. .
(!modified) ,
. ,
3D-.
, ,
Quit .
,
.
( ) ().
ex, .
26 a z,
.
Split:
:gui Split"Create a new window, showing a given file
364
17. elvis
:gui Split;"File to load:" (file) f = filename
:gui Split:split (f)
Split,
, File to load:
filename. (file) ,
, TAB. f = filename
filename f. ,
:split f,
, .
.
.
X11 .
.exrc.
,
, , .
,
^W ^W
xterm elvis.
- ex, X11.
:
autoiconify
, ^W ^W (iconified)
, . autoiconify true,
elvis ,
.
blinktime
0 10,
.
0 .
firstx, firsty, stagger
firstx firsty ,
elvis. , -geo
metry . stagger ,
. ,
.
stopshell
,
ex :shell :stop ^Z .
xterm &,
.
365
xscrollbar
left right
, none .
right.
elvis X1.
:set :color .
elvis .17.4.
17.4. X elvis
(
)
Elvis.Toolbar
Boolean
true
Elvis.Statusbar
Boolean
true
Elvis.Font
Font
fixed
Elvis.Geometry
Geometry
80x34
Elvis.Foreground
Color
black
Elvis.Background
Color
gray90
Elvis.MultiClickTimeout
Timeout
Elvis.Control.Font
Font
variable
Elvis.Cursor.Foreground
Color
red
Elvis.Cursor.Selected
Color
red
Elvis.Cursor.BlinkTime
Timeout
Elvis.Tool.Foreground
Color
black
Elvis.Tool.Background
Color
gray75
Elvis.Scrollbar.Foreground
Color
gray75
Elvis.Scrollbar.Background
Color
gray60
Elvis.Scrollbar.Width
Number
11
Elvis.Scrollbar.Repeat
Timeout
Elvis.Scrollbar.Position
Edge
right
Timeout , Edge
: left, right none.
X- X11 /
, X-.
, KDE
GNOME. xrdb.
366
17. elvis
, X elvis.font:
10x20, 10x20.
normalfont.
.152. elvis
:
\|
.
\(...\)
,
.
\+
.
\?
.
\@
.
\=
,
. , hel\=lo l
hello.
\{...\}
, x\{1,3\},
x, xx xxx. POSIX (
..) .
elvis,
.
, ex,
Elvis ex history.
elvis,
.
367
,
.
,
. ,
Backspace. vi,
Backspace ,
, !
Elvis ex history (
) TAB
. , elvis
. ,
.
,
.
, elvis .
, .
,
^V. ,
inputtab tab Elvis ex history
:
:(Elvis ex history)set inputtab=tab
. 157.
elvis ;
.17.5 17.6.
17.5. elvis
po[p][!]
,
.
vi, ^] elvis ,
, ,
.
HTML (
.376) , ,
368
17. elvis
^]
,
, tags .
.
^T
,
.
:set elvis .
.17.7.
17.7. elvis
taglength, tl
,
. , ,
, .
tags, tagpath
/ ,
tags. elvis tags
, .
( DOS/Win
dows), .
tags,
tags .
TAGPATH.
tagstack
true, elvis
. :set nota
gstack.
elvis ,
8.
ctags ( elvtags,
).
.
!_TAG_:
!_TAG_FILE_FORMAT
!_TAG_FILE_SORTED
!_TAG_PROGRAM_AUTHOR
!_TAG_PROGRAM_NAME
!_TAG_PROGRAM_URL
!_TAG_PROGRAM_VERSION
369
2
/supported features/
1
/0=unsorted, 1=sorted/
Steve Kirkendall
/kirkenda@cs.pdx.edu/
Elvis Ctags
//
ftp://ftp.cs.pdx.edu/pub/elvis/README.html //
2.1
//
elvis .
, elvis .
, ,
.
( ^[ :tag),
..
.
,
. .
-, .
:browse,
HTML.
.
, tagprg,
,
, .
elvis
undolevels
.
( ).
,
6 (,
),
. undolevels
,, 100.
undolevels ,
. u .
( ) (
) ^R (Ctrl-R).
elvis undolevels ,
UNIX-vi.
.
.357.
undolevels u
^R .
370
17. elvis
elvis
.
UNIX elvis
.
elvis.brf binary.
. 8-
, ^X, .
. elvis.brf hex
.374.
-
elvis - :set nowrap.
sidescroll ,
. ^W S
.
,
,
.17.8.
17.8. elvis
^V
elvis ( ) .
,
. :
The 6th edition of <citetitle>Learning the vi Editor</citetitle>
brings the book into the late 1990’s.
In particular, besides the “original” version of
<command>vi</command> that comes as a standard part of every Unix
system, there are now a number of freely available “clones”
or work-alike editors.
. ,
(. .17.9).
371
17.9. elvis
c, d, y
, . ,
d .
<, >, !
, .
,
.
d, ,
:
The 6th edition of <citetitle>Learning the vi Editor</citetitle>
brings the 90’s.
In particulo;original” version of
<command>vi as a standard part of every Unix
system, thef freely available “clones”
or work-alike editors.
elvis,
.
-
17.10. elvis
cc[!] [args]
ccprg
C.
.
mak[e][!] [args]
makeprg
,
( , make).
er[rlist][!] [file]
cc .
. ,
hello.c :cc, elvis .
:cc ,
C. ,
.
:cc ccprg. "cc ($1?$1:$2)".
$2, $1 , :cc. ,
372
17. elvis
ccprg ,
cc (
, ccprg ).
:make ,
.
makeprg, "make $1".
, :make hello, hello, :make
1.
elvis make ,
.
,
. :errlist .
.
:errlist filename,
.
* () vi :errlist.
.
, elvis
.
,
,
.
elvis :display
syntax. . ( elvis
.376.)
:color. , .
, syntax :
comment
.
function
.
keyword
.
1
, ,
Makefile .
. . .
373
prep
C C++.
string
( "Don't panic!" awk).
variable
, .
other
,
, (,
, C typedef).
,
: normal, bold, italic, underlined, emphasized, boxed,
graphic, proportional fixed ( ).
. :
:color function bold yellow
,
elvis.syn.
.
awk:
# Awk. This is actually for Thompson Automation's AWK compiler, which is
# somewhat beefier than the standard AWK interpreter.
language tawk awk
extension .awk
keyword BEGIN BEGINFILE END ENDFILE INIT break continue do else for function
keyword global if in local next return while
comment #
function (
string "
regexp /
useregexp (,~
other allcaps
,
- elvis.
,
,
, . (
:lpr .376.)
, Linux,
, . -
, , (normal)
(italic). ( Linux)
.
GNU/Linux elvis,
374
17. elvis
C, ,
. ; ,
.
elvis ,
.
, .
, .
,
!
elvis :
nvi,
, .
elvis.msg elvis path Elvis
messages.
: .
.
, ,
.
, elvis.
, WYSIWYG.
.
.
-
elvis ( ) ,
.
.
elvis vi, -
vi. (
vi, .
,
.)
375
:safely security
.exrc ,
. security=safer,
,
,
( security). elvis
. ,
.
ex
(
(expression evaluator). C
:if, :calc :eval. -
, elvis
.
elvis vi ( :map).
.
ex
:alias ex.
alias csh. , :safer
:safely,
elvis.
%
% .
#if, #else #endif, syntax.
syntax
, tags
, .
:help set spell.
.
. :help :fold.
, elvis
. :help :region. ,
:load since :rcssince ,
RCS.
376
17. elvis
elvis .
,
WYSIWYG. .17.11.
17.11. elvis
normal
; ,
.
syntax
normal, .
hex
,
.
.
html
-.
.
man
man-. nroff
-man.
tex
TEX.
:normal
normal. :display
mode. ^W d
.
WYSIWYG
html man. -
, elvis.
html -,
HTML .
HTML-
elvis. , .
html,
normal:
<html><head>
<title>Elvis 2.0 Sessions</title>
</head><body>
<h1>10. SESSIONS, INITIALIZATION, AND RECOVERY</h1>
This section of the manual describes the life-cycle of an
edit session. We begin with the definition of an
377
man ,
(manpage),
, .
- :
Troff source was never designed to be interactively edited, and although I
did the best I could, attempting to edit in man mode is still a disorienting
experience. Isuggest you get in the habit of using normal mode when making
changes, and man mode to preview the effect of those changes. The ^W d
command makes switching between modes a pretty easy thing to do.
(: troff
, ,
man .
normal
man . ^W d
.)
, , html, man,
:color,
.372. man. ,
Linux (.B) .
(.B), (.I) .
.17.12.
17.12. elvis
mode. lang
syntax.
no[rmal]
:display normal,
.
378
17. elvis
bufdisplay ,
.
elvis.arf (. )
, normal.
, elvis WYSIWYG
. :lpr (
, ) .
.
, .
:lpr ,
.17.13.
17.13. elvis
lptype, lp
lpconvert, lpcvt
, ASCII
Latin-8 ASCII PC-8.
lpcrlf, lpc
CR/LF.
lpout, lpo
lpcolumns, lpcols .
lpwrap, lpw
lplines, lprows
lpformfeed, lpff
lpoptions, lpopt
,
PostScript.
lpcolor, lpcl
PostScript MS Win
dows.
lpcontrast, lpct
;
lpcolor.
. elvis
, .17.14.
PostScript,
lptype ps ps2. ,
.
379
17.14. lptype
ps
PostScript, .
ps2
PostScript, .
epson
;
.
pana
Panasonic.
ibm
IBM.
hp
Hewlett-Packard -PostScript
.
cr
- ;
.
bs
backspace.
nroff UNIX.
dumb
ASCII, .
-
elvis
: ,
.
ex .
, elvispath:
elvis.brf
(.brf Before Read
ing a File). elvis
, . ,
binary,
( CR/
LF) LF.
elvis.arf
(.arf After Reading a File).
,
.
elvis.bwf
(.bwf Before Writing a File),
,
.
.bak. ,
backup.
380
17. elvis
elvis.awf
(.awf After Writing a File).
, , ,
(hook) .
.
elvis .
.
, elvis Vim
:autocmd. -.
elvis
(Steve Kirkendall) ,
, 1 :
GDB (GNU Debugger)
.
, viminfo Vim.
,
JavaScript HTML.
elvis http://
elvis.vi-editor.org/.
ftp ftp://ftp.cs.pdx.edu/pub/elvis/elvis-2.2_0.tar.gz.
elvis .
perl- Artistic License.
doc/license.html .
elvis UNIX, OS/2, MS-DOS MS Win
dows. UNIX Windows
, MS-DOS .
:
ftp -, 2
configure, make:
$ gzip -d < elvis-2.2_0.tar.gz | tar -xvpf ...
elvis 2003
. . . .
381
$ cd elvis-2.2_0; ./configure
...
$ make
...
elvis .
make install.
,
, /usr/bin,
/usr/share . /usr/local,
--prefix configure.
elvis,
(Steve Kirkendall) kirkenda@cs.pdx.edu.
18
18.
(Paul Fox) vile
:
,
.
, vile ,
vi. 1990
, .
10 vi, Micro
EMACS ,
.
1
9.8, 7
2010. . . .
383
: !
?. ,
, , 1991 1992,
. ( :
7.3 1997.)
( ) , ,
. vile
ex. ,
,
. vile
.exrc,
.
, .
/ vile,
.exrc.
vile vi ex,
view.
. vi,
.
384
:
-c command, + command
vile ex.
-c.
-h
vile .
-R
.
( vile,
view, readonly).
-t tag
tag.
-T, ,
-t X11.
-v
vile . ,
.
-?
vile
.
@cmdfile
(
.vilerc) ( VILEINIT).
, vile
POSIX- -c ( +):
-g N
. +N.
-s pattern
vile
. +/pattern.
-
vile ( )
ASCII vile.hlp. :help (
:h) .
vi. ASCII,
.
385
vile
,
. :
:show-commands
,
vile .
,
. , ,
.
:apropos
,
.
.
:describe-key
, . ,
x delete-next-character.
:describe-function
, .
, delete-next-character
.
:apropos, :describe-function :describe-key
, ( , ..
), ,
(
), ,
.
:describe-function next-line:
"next-line"
^J
or
"down-arrow"
or
"down-line"
or
"forward-line"
(motion: move down CNT lines )
^N
#-B
. ( #-B
vile .
:show-key-names.)
VILE_STARTUP_PATH
, 1.
Win32 ,
OpenVMS .
386
VILE_HELP_FILE
( vile.hlp).
- ,
, ,
.
xvile
:
1. ( xvile).
XVILE_MENU,
. .vilemenu.
X111.
vile, xvile winvile
.
:
2. ,
@cmdfile, .
,
.
3. VILEINIT,
. .
4. VILE_STARTUP_FILE,
. , UNIX
.vilerc, vile.rc.
5. ,
. .
:
6. , ,
.
7. , -c.
.
, vile
( UNIX vi /
) .exrc .vilerc :source .exrc
, vile.
winvile .
Win32.
387
vile .
MicroEMACS
vi.
Emacs
, vile vi,
.
elvis Vim, :split1 ,
ex :e filename,
. .
, vi .
.18.1 ,
ch12.xml2, :split :e !zcat chapter.xml.gz vile.
.18.1. vile
Vim,
ex. ,
. ,
1
vile, .
split-current-window.
, 12.
.
388
I, , ,
[modified].
vile Emacs
. .18.1.
, delete-otherwindows.
18.1. vile
delete-other-windows
^O, ^X 1
, .
delete-window
^K, ^X 0
,
.
edit-file, E, e
^X e
( ^X e
)
.
find-file
^X e
, edit-file.
grow-window
count
.
move-next-window-down ^A ^E
(
) count .
move-next-window-up
^A ^Y
(
) count .
move-window-left
^X ^L
count
, count .
move-window-right
^X ^R
count
, , count .
next-window
^X o
position-window
z where
,
where, where
: (., M, m),
(ENTER, H, t) (-, L, b).
previous-window
^X O
resize-window
count . count
.
restore-window
,
save-window.
save-window
restore-window.
scroll-next-windowdown
^A ^D
count . count
.
389
scroll-next-window-up ^A ^U
shrink-window
split-current-window
^X 2
view-file
set-window
count . count
.
count
. count
.
; count
1 2 ,
. count
.
.
.
historical-buffer
.
,
_
. Tab (back-tab)
,
.
toggle-buffer-list
/ ,
vile.
(Kevin Buettner), (Thomas Dickey)
(Paul Fox), .
vile X11,
, Xt.
No Toolkit, ,
(bulletin board) . ,
Motif, Athena OpenLook1.
Motif Athena,
.
GUI Win32, OLE
Unicode. .
390
, :
,
(panes). ,
, .
vile ,
.
xvile
xvile ,
.
xvile ,
. vile
configure1. :
--with-screen=value
. tcap
termcap/terminfo. curses, ncurses, ncur
sesw, X11, OpenLook, Motif, Athena, Xaw, Xaw3d, neXtaw ansi.
--with-x
X Window System. No Toolkit.
--with-Xaw-scrollbars
Xaw
vile.
--with-drag-extension
/ Xaw.
xvile
Motif xvile.
Athena.
.18.2 :
1. man- vile,
.
2. misc.c tin, (
, ,
, ).
3. [Completions] (
) .
( ):
1
configure UNIX .
OpenVMS vmsbuild.com.
.
391
.18.2. xvile
.18.3 :
1. [Help], , ,
( , ).
2. [Buffer List], , (#)
charset.c. % () ,
[Buffer List] .
* , . 0 2
charset.c misc.c. , [Buffer List]
(12425 89340). 1 (<vile.1>)
(manpage), .
392
1. 3 (color.c)
, u, .
3. [Completions] .
co,
Completions prefixed ,
, TAB: vile
, ,
2.
.18.3. vile
<vile.1> ,
,
.
[Completions] .
. ,
vile : .
393
. ,
, . , ,
[Buffer List].
,
.
,
. Athena No Toolkit
,
() .
. ,
, .
, Motif .
.
.
,
,
.
( ),
. xvile No Toolkit
.
,
.
.
, Ctrl
.
.
, vile.
, Ctrl
. , ,
. Ctrl
. , xvile ,
. .18.2.
18.2. vile
Ctrl-
, .
Ctrl-
Ctrl-
,
.
394
.
, , .
, ,
, .
, ,
, 4j. , d4j,
.
. d,
,
. ,
.
, .
PRIMARY () .
,
. ,
, Ctrl
.
,
, , .
, , ,
.
.
.
, ,
.
, , ,
.
( ),
, , ,
.
, Ctrl .
.
.
Shift,
.
( xvile),
.
395
(Clipboard)
X
PRIMARY-. ,
.
CLIPBOARD
. Sun
COPY,
PASTE.
xvile ( ), , ,
- CLIPBOARD
PRIMARY. ( ,
, .)
xvile : copy-toclipboard paste-from-clipboard. copy-to-clipboard
(clipboard
kill register), ; .
, xvile
. paste-from-clipboard
CLIPBOARD.
, Sun
.vilerc,
COPY PASTE:
bind-key copy-to-clipboard #-^
bind-key paste-from-clipboard #-*
xvile ,
.
,
. vile
, .Xdefault.
Motif Athena .
.vilemenu
. xvile :
, ,
.vilerc xvile.
(,
[Buffer List]).
396
, ).
,
, vile
.
winvile
winvile ,
(interim patch versions). Make-
Microsoft (makefile.wnt) Borland (makefile.tbc).
,
OLE, perl . GUI Win32
.
winvile
.18.4 18.5 Win32 winvile.
No Toolkit X11
.
, Motif.
397
398
, .
CD winvile.
Win32, .
winvile Windows Favorites (
).
( ) (
)
( ). ,
winvile.
.18.6. winvile
.152. vile
, extended nvi.
POSIX ,
[[:alnum::]], (
399
) , {,10}.
nvi
, :
\|
: house\|home.
\+
.
\?
.
\(...\)
*, \+ \?,
(\1, \2
..).
\s, \S
.
\w, \W
, (-
, _), ,
, . , \w\+
C/C++1.
\d, \D
.
\p, \P
.
.
vile escape- \b, \f, \r, \t
\n . Backspace,
, ,
, .
, vile perl- \u\L\1\E, ,
vi. :s/\(abc\)/\u\L\1\E/, vi abc,
vile perl Abc. .
,
, ; .
400
vile,
.
vile ex
[History]. history,
true. ,
, [History] .
show-history ,
[History].
-.
, [History]
.
, .
( , BACKSPACE).
.
- vi, miniedit ( ^G). vile -
, mini-hilite.
reverse, . vi
vi .
vile, ,
i, I, a A. vile , ,
,
-.
vile
,
. , :set vile
Global value:. ,
.
ex .
TAB, vile .
TAB , ,
.
vile, , , ( ), ,
(, )
401
( , , ,
stty).
, .
vi ,
,
. Emacs
,
.
. 157.
vile .
vi.
vi,
. .18.3 vile.
18.3. vile
next-tag
tags.
pop[!]
,
.
show-tagstack
, .
.
vi .18.4.
18.4. vile
^]
tags ,
, .
.
^T, ^X ^]
,
.
^A ^]
, :next-tag.
, vile
, .18.5.
402
18.5. vile
pin-tagstack
,
(pin).
false.
tagignorecase .
false.
taglength
,
. , , ,
.
tagrelative
tags
tags
, tags.
tags
tags,
, . vile
tags ,
, . tags
.
tagword
, ,
, ,
. ,
vile vi.
vile ,
. elvis Vim,
, , nvi, .
. vi
.
vile
undolimit. 10,
10 . ,
,
.
, u ^X u.
. .
vi, u 1,
^X u .
^X r . . ^X r,
. ^X u ^X r , vile
.
1
. . . .
403
vile
.
.
. 8-
^V, x
, 0 , .
16- Unicode, ^V,
u, .
file-encoding
(utf-8, utf-16 utf-32), vile UTF-8,
.
, .
vile
. , (
UNIX)
. vile (
, , , ,
, ),
, -ASCII .
, vile
. ,
, :
vile
,
.1
vile POSIX,
,
.
(, to
kens) , tags, .
.
.
, 8- .
, ISO-8859-7 (),
UTF-8,
. vile ,
1
UNIX,
.
404
UTF-8 ( ), el_GR.UTF-8. ,
8-
, el_GR.
,
UTF-8, UTF-8.
vile
Unicode .
8- , ,
8-, 8- ,
Unicode (
).
.
.
,
, vile .
vile ,
, :
.
(CR, LF CR/LF).
Unicode.
, Unicode.
(
) ,
. , vile
:
,
recordseparator.
,
nonewline.
UTF-16 UTF-32 UTF-8,
file-encoding.
vile ,
.
.162,
vile ^XS ^XR.
, - .
405
,
, . ^X S
, ^X R .
, .vilerc (
vile
.411),
/ ?:
bind-key incremental-search /
bind-key reverse-incremental-search ?
visual match (
),
. .vilerc:
set visual-matches reverse
vile
. ,
= ,
.
-
- .163,
vile :set nolinewrap.
, .
< >. sideways
, vile
. sideways ,
.
.
vile elvis Vim , ,
.
(quoted motion) q.
q, vi,
, q,
. vile .
q . 1q ( , q)
, 2q , 3q
.
,
, d y. , d3qjjwq
, .
, ,
^S. , d ^S .
406
, 1.
,
( `),
( '). , (,
, mb) `b 'b
d'b , d`b
. `
, '.
vile . \
.
` ,
. , .
, d\b
,
, b.
ma
3jfr
^A ~\a
(Paul Fox) .
407
,
, .18.6.
18.6. vile
^A r
>
. , ^A r,
.
<
. , d,
.
. vile ,
.
.
.
, ,
.
^A u
^A l
^A ~
^A SPACE
p, P
. vile
, .
^A p, ^A P
,
.
.
vile.
-
vile
vi, .18.7.
Entering directory XXX Leaving direc
tory XXX, GNU make,
, .
, [Error Expressions]. vile
, ^X ^X.
408
.
,
, , .
- , , ,
,
.
18.7. vile vi
^X !command ENTER
,
[Output].
^X ^X
. vile
.
vile ,
.
,
. , ^X!command
[Output], :e !command
[!command]. .
:error-buffer,
( ,
).
egrep.
vile .
. vile
.
,
.
,
.
.
, ,
.
71 ,
man- UNIX.
. , C, C++ Java
, .
409
vile ,
, . .18.8.
18.8. vile
. vile ,
,
(
.412).
:HighlightFilter
,
vile autocolor,
.
:HighlightFilterMsg ^X-q
HighlightFilter.
a.
:HighlightClear
.
.
^X-Q
:set-highlighting
majormode
majormode
.
:show-filtermsgs
.
, ,
vile [Filter Messa
ges], ,
.
1990-
vile, , .
.
, ,
,
(, , ).
( .keywords), majormode .
- .
:which-keywords, , vile ,
. . 18.1.
18.1. :which-keywords cmode
Show which keyword-files are tested for:
cmode
410
./.c.keywords
$HOME
~/.c.keywords
~/.vile/c.keywords
$startup-path
* /usr/local/share/vile/c.keywords
vile :
vile
vile vi.
Emacs,
.
vile .
, .
, .
411
vile
vi
,
. , x ,
i .
,
( ).
vile, Emacs MicroEMACS,
. ,
,
delete-next-character delete-previous-character.
, delete-nextcharacter x.1
vile
, .
.
: :bind-key,
,
. , .vilerc
:
bind-key incremental-search /
bind-key reverse-incremental-search ?
/ ? ,
.
vile
, . ,
, ,
. GNU Emacs
Lisp. vile
.
Emacs, vi
.
.
, , ENTER.
vi,
, .
1
412
ex, (Paul) ,
:s (substitute).
:
, .
,
perl awk.
:1,$s/perl/awk/gENTER .
vile :
:1,$s
substitute pattern:
vile .
.
perl/
replacement string:
/
. .
awk/
vile ex.
, (:r)
. , ENTER.
, ex vile , .
,
(:/now/,/forever/s/perl/awk/g),
(m) .
.
(major mode)1 ,
.
, ,
.
vile :
(Universal), .
(Buffer), .
vile .
413
(Window), (
).
(buffer) (window)
. ( ,
) () .
, .
, ,
.
vile : cmode
C C++ vile mode ,
. cmode %
C (#if, #else #endif).
({ }) C.
tabstop shiftwidth
.
, . ,
(Thomas Dickey),
shmode Bourne.
( Bourne, ksh, bash zsh,
.)
define-mode sh
set shsuf "\.sh$"
set shpre "^#!\\s*\/.*sh\\>$"
define-submode sh comment-prefix
define-submode sh comments
define-submode sh fence-if
define-submode sh fence-elif
define-submode sh fence-else
define-submode sh fence-fi
"^\\s*/[:#]"
"^\\s*/\\?[:#]\\s+/\\?\\s*$"
"^\\s*\\<if\\>"
"^\\s*\\<elif\\>"
"^\\s*\\<else\\>"
"^\\s*\\<fi\\>"
414
"^#!\\s*\/.*sh\\>$"
"^\\s*/[:#]"
"^\\s*/\\?[:#]\\s+/\\?\\s*$"
"^\\s*\\<if\\>"
"^\\s*\\<elif\\>"
"^\\s*\\<else\\>"
"^\\s*\\<fi\\>"
~endwith
vile 90
. , :showmajormodes.
suffix prefix vile
, .1
.18.9 .
18.9.
. ,
, .
before
. ,
, .
mode-filename (mf) , ,
.
, .
mode-pathname (mp) , ,
.
,
preamble (pre)
,
.
after
qualifiers
suffixes (suf)
, preamble suffixes.
ll, , any,
.
,
,
.
, .
, :
:setl cmode
1
,
, . . B.5,
.
415
c mode1,
. , , :
:set-h cmode
(set-highlighting; . .18.8).
vile ,
MicroEMACS.
, ( )
$, %.
, &.
~.
@, ,
. macros.doc
,
:
~if &sequal %curplace "timespace vortex"
insert-string "First, rematerialize\n"
~endif
~if &sequal %planet "earth" ;If we have landed on earth...
~if &sequal %time "late 20th century" ;and we are then
write-message "Contact U.N.I.T."
~else
insert-string "Investigate the situation....\n"
insert-string "(SAY 'stay here Sara')\n"
~endif
~elseif &sequal %planet "luna" ;If we have landed on our neighbor...
write-message "Keep the door closed"
~else
setv %conditions @"Atmosphere conditions outside? "
~if &sequal %conditions "safe"
insert-string &cat "Go outside......" "\n"
insert-string "lock the door\n"
~else
insert-string "Dematerialize..try somewhen else"
newline
~endif
~endif
, .
vile
Tardis.
1
setl , :set
cmode , vile .
416
,
Bourne,
. ,
vile ( ).
, ,
.
, read-hook write-hook
,
. ,
- elvis Vim.
.
, ,
vile. macros.doc
.
, :
vile
vile ,
[Standard Input],
. , .
Windows
dos, true, , vile
, .
Windows UNIX GNU/Linux.
^A f ,
.
417
C (, * #)
( >). UNIX fmt,
.
modeline-format , , vile
.
, ,
, ,
.1
,
printf(3). , %b , %m
, %l , ruler.
, ,
.
vile .
vi vile .
,
, vi.
- vile http://invisible-island.net/vile/vile.html.
ftp ftp://invisible-island.net/vile/vile.tar.gz.
vile.tar.gz
.
ANSI C. UNIX,
OpenVMS, MS-DOS, GUI- Win32, BeOS, QNX
OS/2.
vile . ftp
-, , configure
make:
$ gzip -d < vile.tar.gz | tar -xvpf ...
$ cd vile-*; ./configure
...
$ make
...
vile modeline. ,
vile modeline vi,
, .
418
vile .
make install.
, , ,
, configure --with-builtinfilters. flex ( 2.54a ),
lex, UNIX
. configure flex,
.
vile,
vile@nongnu.org.
.
(Thomas Dickey) dickey@invisible-island.net.
IV
IV.
IV ,
vi. :
vi, ex Vim
C
D vi
A
A.
vi, ex Vim
vi. , (
ex,
), Vim.
:
vi
vi
vi
ex
ex
vi:
vi [options] file
vi [options] +num file
vi [options] +/pattern file
,
num , pattern.
file , vi .
422
vi ex ,
. .
, Vim, .
+[ num ]
num
, num .
+/pattern
,
pattern. (ex , .exrc
nowrapscan, ex
.)
+?pattern
,
pattern.
-b
. {Vim}
-c command
ex. vi
c, Vim 10 .
, +command, .
--cmd command
-c,
. {Vim}
-C
Solaris vi: -x, ,
.
Vim: vi.
-d
diff. vimdiff. {Vim}
-D
. {Vim}
-e
ex (, ).
-h
. {Vim}
vi, ex Vim
423
-i file
file
(~/.viminfo) Vim.
{Vim}
-l
Lisp Lisp (
).
-L
, -
(
). Vim -r.
-m
write,
. {Vim}
-M
. {Vim}
-n
;
. {Vim}
--noplugin
. {Vim}
-N
Vim , vi. {Vim}
-o[num]
Vim , num.
. {Vim}
-O[num]
Vim num- ,
( ). {Vim}
-r [file]
.
file
. file ,
.
-R
.
424
-s
-s
-S
-t
-T
-u
, .
.
-. Vim -e.
scriptfile
scriptfile,
. {Vim}
commandfile
,
, com
mandfile. vim -c 'source
commandfile'. {Vim}
tag
, tag,
.
type
.
$TERM. {Vim}
file
.vimrc,
. file NONE, Vim
,
, vi. NORC,
, .
-v
( vi
).
--version
. {Vim}
-V[num]
. ,
.
,
.
10 ( ). {Vim}
-w rows
,
rows .
( ).
vi .
Vim .
vi, ex Vim
425
-W scriptfile
scriptfile ,
. -s. {Vim}
-x
,
crypt (
).1
-y
vi . Vim
. Vim evim. {Vim}
-Z
Vim .
. {Vim}
ex
vi, .
(, ,
). ex vi visual vi.
vi Q, vi ex.
ex :
:x
( ).
:q!
:vi
vi.
vi
:
vi
vi
.
:
ex
1
crypt .
.
426
A
UNIX
vi
.
i.
, ESC. ,
,
.431.
vi
vi :
[n] operator [m] motion
:
c
, motion
cc, dd yy. ,
,
. (, cf.
.) n m
, .
n m, n m .
, ,
:
(word)
(
) . ,
,
.
(sentence)
., ! ?, .
(paragraph)
,
para=.
(Section)
nroff/troff,
sect=.
vi, ex Vim
427
(Motion)
,
, .
2cw
d}
d^
5yy
y]]
cG
.432
.
( Vim)
Vim ,
. ,
,
. Vim
.
.
.197.
v
V
CTRL-V
.
.
.
,
:
/
ex.
UNIX,
.
.
, , ENTER.
,
CTRL-G.
428
vi
vi ,
, Vim ,
.
vi
(, Page Up, Page Down, Home, Insert Delete),
. ,
, . vi
,
. , ,
, .
, ,
.
h, j, k, l
(Spacebar)
BACKSPACE
CTRL-H
, , , (, , , ).
.
.
.
w, b
W, B
e
E
ge
gE
), (
}, {
]], [[
][, []
/ (, ,
).
/ (
).
.
.
. {Vim}
. {Vim}
/ .
/ .
/ .
/ . {Vim}
( ).
, ,
, . Vim wrap
.
429
vi, ex Vim
0, $
/ .
^, _
+, ENTER
/ .
num |
.
num .
g0, g$
/ . {Vim}
g^
. {Vim}
gm
. {Vim}
gk, gj
/ . {Vim}
num H
num .
num L
num .
CTRL-F, CTRL-B
CTRL-D, CTRL-U
CTRL-E, CTRL-Y
z ENTER
/ .
/ .
/ .
.
z.
zCTRL-L
CTRL-R
.
( ).
vi: ( ).
Vim: .
/ pattern
/ pattern /+ num
/ pattern /- num
? pattern
? pattern ?+ num
? pattern ?- num
:noh
pattern .
ENTER.
num pattern. pattern
.
num pattern. pattern
.
pattern .
ENTER.
num pattern. pattern
.
num pattern. pattern
.
. {Vim}
430
A
n
f x
.
. {Vim}
.
. {Vim}
.
, . {Vim}
.
, . {Vim}
(, , ),
.
x.
F x
x.
t x
,
x.
,
x.
#
g*
g#
%
T x
,
f, F, t T.
f, F, t T.
CTRL-G .
. {Vim}
gg
num G
num.
: num
num.
m x
x .
` x
( ) x.
' x
() , x.
``
( ) ,
.
() , .
''
'"
`[, `]
( ) ,
. {Vim}
( , ) /
. {Vim}
vi, ex Vim
431
'.
(, ) ,
, . {Vim}
( , ) .
{Vim}
(, ) , . {Vim}
'0
(, ) Vim. {Vim}
:marks
. {Vim}
'[, ']
`.
gI
a. {Vim}
b.
S
ESC
a
b
1. . . .
. . . .
:
BACKSPACE
DELETE
TAB
CTRL-A
CTRL-D
CTRL-E
CTRL-H
CTRL-I
CTRL-K
CTRL-N
CTRL-P
CTRL-T
.
.
.
. {Vim}
shiftwidth. {Vim}
, . {Vim}
( Backspace).
.
.
.
{Vim}
.
{Vim}
shiftwidth. {Vim}
432
A
CTRL-U
CTRL-V
CTRL-W
CTRL-Y
CTRL-[
.
.
.
, . {Vim}
.
,
, stty.
.
, c, d y.
,
:
cw
cc
c$
C
dd
num dd
d$
D
dw
d}
d^
d/ pat
dn
df x
dt x
dL
dG
gqap
g~w
guw
gUw
p
gp
.
.
.
c$.
.
num .
.
d$.
.
.
.
.
.
x .
x ( ).
.
.
textwidth. {Vim}
. {Vim}
. {Vim}
. {Vim}
.
p,
. {Vim}
vi, ex Vim
433
gP
P, . {Vim}
]p
p, . {Vim}
[p
P, . {Vim}
.
x.
P
r x
, . ESC
.
.
4s
u
CTRL-R
R text
. {Vim}
.
5X
.
~
CTRL-A
CTRL-X
.
.
.
1 , . {Vim}
1 , . {Vim}
a z.
.
Y
yy
" x yy
Y.
x.
ye
yw
y$
ye, .
.
" x dd
x.
" x d
x.
" x p
x.
y]]
gJ
J, . {Vim}
:j
J.
:j!
gJ.
434
ZZ
vi ,
.
:x
:wq
ZZ.
.
:w
:w file
file.
:n , m w file
file n m.
file .
:w %. new
file file.new.
:q
vi ( , ).
:q!
vi ( ).
vi ex.
:vi
vi Q.
.
%
#
:e file
:e!
file,
.
.
:e + file
file.
:e +num file
file num.
:e #
:ta tag
tag.
:n
:n!
:n files
files.
:rewind
CTRL-G
:args
.
.
:prev
(Vim)
Vim. . split, vsplit resize
435
vi, ex Vim
ex .440.
^.
:new
:new file
file .
:sp [file]
. file,
.
:sv [file]
:sp,
.
file,
.
:sn [file]
:on
,
.
.
:res num
num .
:wa
:qa
^W s
:sp.
^W n
^W ^
:new.
( )
.
^W c
:clo.
^W o
:only.
, /
.
.
:hid
^W j, ^W k
^W p
^W t, ^W b
, /
.
, / .
^W K, ^W B
/ .
^W H, ^W L
/ .
^W r, ^W R
/.
^W +, ^W -
/ .
^W =
^W h, ^W l
:r file
file .
:r !command
command .
: num r !command
,
num ( 0).
436
A
:!command
!motion command
: n , m !command
num!!command
:!!
:sh
CTRL-Z
:so file
vi.
, motion, UNIX
command; .
command n m .
command num .
.
; EOF .
(
fg).
ex file.
:ab in out
in out .
:unab in
in.
:ab
:map string
sequence
string
sequence.
#1, #2 ..
string.
:unmap string
:map
:map! string
sequence
:unmap! string
:map!
qx
q
@x
,
.
string se
quence .
(,
CTRL-V).
,
.
, x.
,
. {Vim}
. {Vim}
, x.
@ @@.
vi ,
:
g, K, q, V v
^A, ^K, ^O, ^W, ^X, ^_ ^\
_, *, \, = #
vi, ex Vim
437
= vi, Lisp.
,
.
<
>
<<
>>
>}
<%
==
g
K
^O
^Q
^T
^]
^\
^^
shiftwidth ,
. {Vim}
shiftwidth ,
. {Vim}
shiftwidth ( ).
shiftwidth ( ).
.
,
. ( .)
C ,
equalprg. {Vim}
Vim.
man ( , keywordprg)
, . {Vim}
. {Vim}
^V. {Vim} (
.)
(Solaris vi, Vim, nvi,
elvis vile).
.
ex.
( Ctrl.)
.
vi
:
:set
:set
.exrc
:set
:set ,
. .exrc
vi.
438
.exrc, :
:set x
x; .
:set no x
x.
:set x = value
x value.
:set
:set all
:set x ?
x.
.exrc
ex .
.exrc:
set nowrapscan
set wrapmargin=7
set sections=SeAhBhChDh nomesg
map q :w^M:n^M
map v dwElp
ab ORA O'Reilly Media, Inc.
"
"
"
"
"
"
q Vim , :wn.
v v Vim,
.
ex
ex vi.
ex
. ex vi.
ex ,
ENTER.
ex ,
vi. ( ex.) vi
Q, ex.
ex
ex vi, :
:[address] command [options]
: , ex.
. , ENTER.
vi, ex Vim
439
Address ,
command. options addresses
. ex
ex .440.
ex :
:x
:q!
:vi
vi .
, .
, :
x,y
x y ( x
y). x y ,
. (;)
(,), x y.
1,$ %.
.
x y.
x y, x.
.
.
num.
.
1,$
x , y
x ; y
0
.
num
$
%
x - n
x + n
-[num]
+[num]
' x
''
/pattern/
. 1,$.
n x.
n x.
num .
num .
() x.
( ) .
, .
?pattern?
, .
6.
440
!
,
. ! .
count
. vi, count
, , ,
. , d3 ,
, 3d 3.
file
, . %
, # .
ex
ex , .
-
,
. ,
vi, : .
abbreviate
ab [string text]
string, text
. string text ,
.
: ^M , ^V, ENTER.
:ab ora O'Reilly Media, Inc.
:ab id Name:^MRank:^MPhone:
append
[address] a[!]
text
.
text address
, address .
autoindent, , !. ,
autoindent , ! .
. ,
.
441
vi, ex Vim
:a
Append this line
and this line too.
.
args
ar
args file . . .
(,
). ([]).
Vim,
.
bdelete
[num] bd[!] [num]
num .
!.
. , . {Vim}
buffer
[num] b[!] [num]
num .
, !.
. ,
.
buffers
buffers[!]
. (,
) . !.
ls. {Vim}
cd
cd dir
chdir dir
dir.
442
center
[address] ce [width]
width.
, textwidth. {Vim}
change
[address] c[!]
text
.
text.
autoindent , !.
, .
close
clo[!]
, .
, .
, !
. {Vim}
copy
[address] co destination
, address, destination.
t ( to) copy.
:1,10 co 50
10 50-
delete
[address] d [register] [count]
, address. register,
.
a z.
. count,
count .
443
vi, ex Vim
edit
e[!] [+num] [filename]
filename. filename ,
.
, ,
, !. +num ,
num. num
/pattern.
:e file
:e +/^Index #
:e!
file
f [filename]
filename.
filename.
not edited, ,
. filename
, :w!
.
%, .
#. filename ,
.
:f %.new
fold
address fo
, address.
, .
. {Vim}
foldclose
[address] foldc[!]
address , ,
.
!. {Vim}
444
foldopen
[address] foldo[!]
address , ,
.
!. {Vim}
global
[address] g[!]/pattern/[commands]
commands , pattern,
, address, , pattern,
. commands ,
. commands , pattern,
!. v .
:g/Unix/p
, Unix
:g/Name:/s/tom/Tom/ tom Tom ,
Name:
hide
hid
, ,
.
. {Vim}
insert
[address] i[!]
text
.
text , address,
, address .
autoindent , !.
, .
join
[address] j[!] [count]
.
, (.) ,
) .
, !.
vi, ex Vim
445
:1,5j! ,
jumps
ju
CTRL-I CTRL-O.
,
. .
k
[address] k char
mark; . mark .
left
[address] le [count]
, address, , address
, . count
. {Vim}
list
[address] l [count]
,
^I, $. l :set list.
map
map[!] [string commands]
string
. string
#num,
. ,
!. ,
.
:map K dwwP
:map q :w^M:n^M
:map! + ^[bi(^[ea)
Vim K q,
.
446
mark
[address] ma char
char .
k. 'x ( x, x
char). Vim
. , vi,
. , ,
viminfo, .
marks
marks [chars]
, chars, ,
chars . {Vim}
:marks abc
a, b c
mkexrc
mk[!] file
.exrc, set ex
. ,
. {Vim}
move
[address] m destination
address destination.
:.,/Note/m /END/
, END
new
[count] new
count . {Vim}
next
n[!] [[+num] filelist]
. args. filelist,
447
vi, ex Vim
filelist,
.
+num num. num
, /pattern.
:n chap*
chapter
nohlsearch
noh
hlsearch.
. {Vim}
number
[address] nu [count]
, address,
. number
#. count , address.
only
on [!]
.
(),
!. {Vim}
open
[address] o [/pattern/]
(vi) , address,
, pattern.
Q.
vi, .
(
ssh).
preserve
pre
,
.
448
previous
prev[!]
. {Vim}
print
[address] p [count]
, address. count
, address. P.
:100;+5p
100- 5
put
[address] pu [char]
, char, , address.
char ,
.
qall
qa[!]
.
!. {Vim}
quit
q[!]
.
, !.
,
, q! q. Vim
,
.
read
[address] r filename
filename , address.
filename , .
449
vi, ex Vim
:0r $HOME/data
read
[address] r !command
command ,
address.
:$r !spell %
recover
rec [file]
file .
redo
red
.
CTRL-R. {Vim}
resize
res [[]num]
, num .
+ -, num
. {Vim}
rewind
rew[!]
.
, !.
right
[address] ri [width]
, address ( , address
), width. width
, textwidth. {Vim}
450
sbnext
[count] sbn [count]
count . count ,
. {Vim}
sbuffer
[num] sb [num]
num .
. ,
. {Vim}
set
se parameter1 parameter2 . . .
parameter ,
parameter , ,
. parameter
option nooption.
option=value. ,
all. set option? .
, , B.
shell
sh
.
.
snext
[count] sn [[+num] filelist]
,
. count,
count- . filelist,
filelist,
. +num
num. , num
/pattern. {Vim}
vi, ex Vim
451
source
so file
ex file.
:so $HOME/.exrc
split
[count] sp [+num] [filename]
filename
, filename .
count , count , .
+num
num. , num /pattern. {Vim}
sprevious
[count] spr [+num]
. count,
count- .
+num num. , num
/pattern. {Vim}
stop
st
.
CTRL-Z. fg.
substitute
[address] s [/pattern/replacement/] [options] [count]
pattern
replacement. pattern replacement ,
. count ,
, address. (
Solaris vi.)
c .
g pattern (
).
p , .
452
:1,10s/yes/no/g
:%s/[Hh]ello/Hi/gc
:s/Fortran/\U&/ 3
:g/^[0-9][0-9]*/s//Line &:/
10
Fortran
,
, Line
suspend
su
.
CTRL-Z. fg.
sview
[count] sv [+num] [filename]
split,
readonly. {Vim}
t
[address] t destination
, address, (to)
destination. t copy.
:%t$
tag
[address] ta tag
tags , tag,
.
ctags, , myfunction:
:!ctags *.c
:tag myfunction
tags
tags
. {Vim}
453
vi, ex Vim
unabbreviate
una word
word .
undo
u
,
. vi ,
. Vim .
Vim redo.
unhide
[count] unh
,
. count,
. {Vim}
unmap
unm[!] string
string .
!.
v
[address] v/pattern/[command]
command , pattern.
command , . v g!.
global .
:v/#include/d
, #include
version
ve
.
view
vie[[+num] filename]
edit, read
only. ex,
. {Vim}
454
visual
[address] vi [type] [count]
(vi) , address.
ex , Q. type -, ^ . (.
z ).
visual
vi [+num] file
(vi),
num. , num /pattern.
{Vim}
vsplit
[count] vs [+num] [filename]
split, .
count .
{Vim}
wall
wa[!]
. ,
readonly, !. {Vim}
wnext
[count] wn[!] [[+num] filename]
count- count.
filename, .
+num
num. num /pattern. {Vim}
wq
wq[!]
.
. !
.
wqall
wqa[!]
455
vi, ex Vim
.
! , readonly.
xall . {Vim}
write
[address] w[!] [[>>] file]
, address ( ,
address ), file. file
. >> file,
.
, !.
:1,10w name_list
:50w >> name_list
10 name_list
50
write
[address] w !command
, address, command.
X
X
. ,
:set key, .
, key
. {Vim}
xit
x
, ,
.
yank
[address] y [char] [count]
, address,
char. a z.
.
456
char , . count
, address.
:101,200 ya a
100200 a
z
[address] z [type] [count]
, address
. count .
+
-
.
^
=
( ).
.
.
.
.
&
[address] & [options] [count]
(s). count
, , address. options
, .
:s/Overdue/Paid/
:g/Status/&
Status
@
[address] @ [char]
, char.
address, .
char @, @.
=
[address] =
, address.
.
457
vi, ex Vim
!
[address] !command
UNIX command. address,
command
, ,
. (
.)
:!ls
:11,20!sort -f
1120
<>
[address] < [count]
~
[address] ~ [count]
(
, s)
s. ;
6.
address
address
, address.
ENTER
. ( ex, : vi
.)
B
B.
set So
laris vi, nvi 1.79, elvis 2.2, Vim 7.1 vile 9.6.
Solaris vi
B.1 set.
.
,
. ,
vi set ( .exrc).
.
B.1. set Solaris vi
, .
shiftwidth.
autoprint (ap) ap
. (
.)
()
:n UNIX :!.
beautify (bf)
nobf
( tab,
).
, ex/vi .
( .)
459
edcompatible
noedcompatible ,
(,
),
. ,
ed .
exrc (ex)
noexrc
.exrc,
.
flash (fp)
nofp
hardtabs (ht)
lisp
nolisp
Lisp
. ( ), { }, [[ ]] ,
Lisp.
list
nolist
^I,
$. ( ,
, listp.)
magic
magic
. (), * () []
( )
.
mesg
mesg
vi
.
novice
nonovice
ex, copy read.
number (nu)
nonu
open
open
ex. Solaris vi ,
vi
vi UNIX.
.
(
), .
paragraphs
(para)
{ }. ,
,
troff, .
IPLPPPQP
LIpplpipbp
460
B.1 ()
prompt
prompt
ex (:)
vi Q.
readonly (ro)
noro
,
! write (
w, ZZ autowrite).
(
,
,
).
. noredraw
:
@,
, ESC.
redraw (re)
remap
remap
report
,
. , 6dd
6 lines deleted.
scroll
[ window]
,
^D ^U.
[[ ]]. ,
,
troff, .
shell (sh)
,
(:!) (:sh).
.
.
/bin/sh
shiftwidth (sw) 8
(backward) (^D)
autoindent, << >>.
vi ) }
( {. (
,
.)
.
showmode
,
, OPEN MODE APPEND
MODE.
noshowmode
461
.
.
slowopen (slow)
,
. (
, 8.)
taglength (tl) 0
,
.
() ,
.
tabstop (ts)
tags
tags /usr/lib/ ,
(. ctags UNIX).
tags
vi tags /usr/
lib/tags.
tagstack
tagstack
.
.
term
terse
noterse
timeout (to)
timeout
1- a.
. term.
ttytype
warn
warn
No write since
last change.
window (w)
.
.
wrapmargin (wm) 0
.
,
, .
wrapscan (ws)
ws
writeany (wa)
nowa
(, :map
zzz 3dw), notimeout, zzz
.
(, :map! ^[OB ^[ja) timeout.
vi ESC,
- .
462
nvi 1.79
nvi 1.79 78 , . .B.2
.
.B.1 .
B.2. set nvi 1.79
,
.
. N nvi
;
.
"N%.bak".
backup
cdpath
:cd.
CDPATH
, nvi
,
. ENTER
.
ESC (
^V ^[).
cedit
comment
nocomment
/*, //
#, nvi
.
.
directory
(dir)
TMPDIR /tmp
, nvi
.
extended
noextended
egrep.
filec
, nvi
,
*,
. ESC
(
, ^V ^[.)
, cedit,
, cedit
.
463
iclower
noiclower
,
.
leftright
noleftright
, .
lock
lock
nvi
. ,
.
octal
nooctal
, .
, ,
nvi .
path
recdir
/var/tmp/
vi.recover
,
.
ruler
noruler
searchincr nosearchincr
secure
nosecure
, ! ^Z
vi, !, shell, stop su
spend ex.
.
shellmeta
~{[*?$`'"\
,
ex, ,
,
shell.
showmode
(smd)
noshowmode
. , *.
sidescroll 16
,
leftright.
taglength
(tl)
,
.
() , .
tildeop
notildeop
~
,
.
wraplen
(wl)
wrapmargin,
, ,
,
. wrapmargin
wraplen.
464
elvis 2.2
elvis 2.2 225 , .
.B.3 .
.B.1 .
B.3. set elvis
autoiconify
(aic)
noautoiconify
. X11.
backup (bk)
nobackup
(xxx.bak)
.
.
.
binary (bin)
. X11.
boldfont (xfb)
bufdisplay (bd)
normal
(hex, html, man, normal, syntax tex).
ccprg (cp)
cc ($1?$1:$2)
:cc.
.
.
directory (dir)
display (mode)
normal
,
.
.
elvispath
(epath)
focusnew (fn)
,
:display.
focusnew
.
X11.
(
Windows X11).
font (fnt)
gdefault (gd)
nogdefault
home (home)
$HOME
~
.
. X11.
italicfont (xfi)
locked (lock)
nolocked
,
.
HTML-
.
lpcolor (lpcl)
nolpcl
; :lpr.
lpcolumns
(lpcols)
80
; :lpr.
lpcrlf (lpc)
nolpcrlf
CR/LF
; :lpr.
465
lpformfeed
(lpff)
nolpformfeed
; :lpr.
lpheader (lph)
nolph
;
:lpr.
lplines (lprows) 60
; :lpr.
lpout (lpo)
, :lpr.
!lpr.
.
lptype (lpt)
dumb
; :lpr.
: ps, ps2, epson, pana, ibm, hp, cr,
bs, dumb, html ansi.
lpwrap (lpw)
lpwrap
; :lpr.
makeprg (mp)
make $1
:make.
prefersyntax
(psyn)
never
. , HTML
man
.
never,
; writable,
; local
;
always
.
ruler (ru)
noruler
security (sec)
normal
normal (
vi), safer (
) restricted (
elvis
). ,
:safely,
.
showmarkups
(smu)
sidescroll (ss)
.
vi ( ).
smartargs (sa)
nosmartargs
function
( )
,
.
spell (sp)
nospell
.
tags.
466
B.3 ()
taglength (tl)
,
. ()
, .
tags (tagpath)
tags
tags.
tagstack (tsk)
tagstack
,
.
undolevels (ul)
.
vi.
.
warpback (wb)
nowarpback
xterm, elvis.
X11.
warpto (wt)
don't
^W. don't
, scrollbar
, origin
, corners
(
). X
, ,
.
Vim 7.1
Vim 7.1 295(!) , . .B.4
. .B.1
.
.
- Vim.
B.4. set Vim 7.1
autoread (ar)
noautoread
, , Vim,
,
.
.
.
467
backspace (bs)
,
Backspace. : 0
vi, 1
, 2
,
.
backup (bk)
nobackup
,
.
,
writebackup.
backupdir
(bdir)
., ~/tmp/, ~/
,
.
. ,
. .
()
.
backupext (bex) ~
,
.
binary (bin)
nobinary
,
.
, bin
.
.
.
-b .
cindent (cin)
nocindent
C.
cinkeys (cink)
0{,0},:,0#,!^F,o,O,e ,
. ,
cindent.
cinoptions
(cino)
cinwords (cinw)
C cindent.
-.
if, else, while, do,
,
for, switch
smartindent cindent. cindent
( {...}).
468
B.4 ()
,
.
-.
comments
(com)
compatible
(cp)
cp; nocp,
.vimrc
Vim vi
, .
,
. .vimrc
.
.
completeopt
(cot)
menu,preview
, .
cpoptions
(cpo)
aABceFs
,
,
Vim vi.
,
Vim .
-.
cursorcolumn
(cuc)
nocursorcolumn
,
, CursorColumn.
. .
cursorline
(cul)
nocursorline
,
, CursorRow.
.
cursorcolumn
. .
define (def)
^#\s*define
,
.
C. C++
^\(#\s*define\ |[a-z]*\s*const\s*[a-z]*\).
:set
.
directory
(dir)
., ~/tmp, /tmp
.
, .
, ,
! .
() ,
.
(.)
,
.
equalprg (ep)
,
=. ,
.
469
errorformat
(efm)
(
)
quickfix.
-q
errorfile
.
scanf
.
fileformat
(ff)
unix
,
.
: dos (CR/LF), unix (LF) mac (CR).
Vim
.
fileformats
(ffs)
dos,unix
,
Vim
.
.
formatoptions Vim
: tcq;
(fo)
vi
: vt
, ,
. .
gdefault (gd)
nogdefault
, ,
Vim
.
guifont (gfn)
,
.
hidden (hid)
nohidden
history (hi)
Vim , ,
: 20;
.
vi
: 0
hlsearch
(hls)
nohlsearch
icon
noicon
Vim ,
, .
iconstring.
,
.
iconstring
include (inc)
^#\s*include
inclu
de.
C.
.
470
B.4 ()
isfname (isf)
@,48-57,/,.,-,_,
+,,,$,:,~
,
. -UNIX-
.
@ -
.
isXXX, .
isident (isi)
@,48-57,_,192-255 ,
. -UNIX-
.
@,161-255
,
. -UNIX-
.
makeef (mef)
/tmp/vim##.err
:make. UNIX-
. ## ,
.
makeprg (mp)
make
, :make.
% #
.
,
.
mouse
Vim. MS-DOS, Win32, QNX pterm
xterm.
-.
mousehide (mh)
nomousehide
paste
nopaste
,
Vim
.
.
-.
ruler (ru)
noruler
secure
nosecure
.
,
.vimrc .exrc.
471
shellpipe (sp)
,
:make .
.
shellredir
(srr)
,
.
.
showmode (smd)
Vim
: smd;
,
.
vi
: nosmd
sidescroll (ss) 0
,
.
.
ignorecase,
.
spell
nospell
suffixes
*.bak,~,.o,.h,.
info,.swp
,
, ,
Vim.
taglength (tl)
,
. ()
, .
tagrelative
(tr)
Vim tags
: tr;
.
vi
: notr
tags (tag)
./tags,tags
:tag,
. ./,
,
.
tildeop (top)
notildeop
~ .
,
. 0
vi, u
.
-UNIX-
.
472
B.4 ()
viminfo,
.
:
, Vim
.
-.
viminfo (vi)
writebackup
(wb)
writebackup
.
,
backup.
vile 9.6
vile 9.6 167 (
), (universal),
(buffer) (window) .
101 ,
,
1.
X11 Win32.
.B.5 vile,
, .
, vileinit.rc,
. .B.1 .
B.5. set vile 9.6
alt-tabpos (atp)
noatp
,
( ).
animated
animated
autobuffer (ab)
autobuffer
.
.
,
.
,
. -.
473
autocolor (ac)
.
, .
,
autocolor-hook.
autosave (as)
noautosave
.
,
autosavecnt.
autosavecnt
(ascnt)
256
,
.
backspacelimit
(bl)
backspacelimit
,
, Back
space.
backup-style
off
,
.
: off, .bak
DOS tilde
UNIX Emacs hello.c~.
bcolor
default
,
.
byteorder-mark
(bom)
auto
,
UTF.
auto vile
;
.
check-modtime
cindent
nocindent
C,
, autoindent.
cindent-chars
:#{}( )[]
,
cindent. #
1 : ,
. ,
fence-pairs, ,
.
474
B.5 ()
cmode
off
C.
color-scheme
(cs)
default
fcolor,
bcolor, video-attrs $palette,
define-color-scheme.
comment-prefix
^\s*\(\(\s*[#*>] ,
\)\|\(///*\)\)\+
.
Makefile,
C, .
comments
^\s*/\?\
(\s*[#*>/]\)\+/
\?\s*$
,
.
.
cursor-tokens
regex
vile
:
.
: both, cclass regex.
dirc
nodirc
vile
.
.
dos
nodos
CR
CR/LF, .
dos.
fcolor
default
,
.
fence-begin
/\*
fence-end
\*/
(fences), C.
fence-if
fence-elif
fence-else
fence-fi
^\s*#\s*if
^\s*#\s*elif\>
^\s*#\s*else\>
^\s*#\s*endif\>
,
, else if, else
(fences),
C.
fence-pairs
{}( )[]
,
%.
file-encoding
auto
:
8bit, ascii, auto, utf-8, utf-16 utf-32.
475
filtername (fn)
,
for-buffers kill-buffer
: (globbing)
.
glob
!echo %s
,
(, * ?)
. off , on
,
~.
UNIX
.
highlight (hl)
highlight
history (hi)
history
,
(-)
[History].
.
,
.
ignoresuffix
(is)
\(\.orig\|~\)$
linewrap (lw)
nolinewrap
maplonger
nomaplonger
,
.
meta-insertbindings (mib)
mib
8-
. ,
.
.
(
),
,
,
.
- .
,
-.
476
B.5 ()
modeline
nomodeline
(modeline) vi.
modelines
,
modeline vi.
overlap-matches
overlap-matches
, visualmatches
.
percent-crlf
50
CR/LF, vile
recordseparator crlf.
percent-utf8
90
,
,
UTF-16 UTF-32. file-enco
ding auto,
, vile
UTF-8.
popup-choices (pc)
delayed
,
. off,
, immediate
delayed,
Tab.
popup-msgs (pm)
nopopup-msgs
, vile
[Messages], ,
.
recordseparator
(rs)
lfa
, vile
.
: lf ( UNIX), crlf ( DOS),
cr ( Macintosh) default (lf crlf,
).
resolve-links
noresolve-links
, vile
,
.
-
.
ruler
noruler
,
,
.
, vile.
477
showchar (sc)
noshowchar
recordseparator
. : always, dif
fers (,
), local
( ,
), foreign (,
recordseparator
) never.
showmode (smd)
showmode
,
.
sideways
,
.
0
.
tabinsert (ti)
tabinsert
.
(notabinsert), vile
;
.
tagignorecase
(tc)
notagignorecase
taglength (tl)
,
.
, , ,
.
,
.
. (
.)
tagrelative
(tr)
notagrelative
tags
, tags.
tags
tags
,
, .
tagword (tw)
notagword
,
,
.
478
B.5 ()
undolimit (ul)
10
.
.
unicode-as-hex nounicode-as-hex
(uh)
unprintableasoctal (uo)
,
Unicode (, utf-8,
utf-16 utf-32), -ASCII
\uXXXX,
.
nounprintableas-octal
.
,
.
.
visual-matches none
.
: none , underline,
bold reverse
(
,
). ,
.
xterm-fkeys
noxterm-fkeys
xterm
Shift-,
Ctrl- Alt-
,
.
xterm-mouse
noxterm-mouse
xterm.
-.
xterm-title
noxterm-title
,
xterm.
vile
.
TERM,
xtermmouse.
C
C.
,
I. .
vi [open mode]
, .
:q
TERM.
.
.
:
Visual needs addressable cursor or upline capability
Bad termcap entry
Termcap entry too long
terminal: Unknown terminal type
Block device required
Not a typewriter
, - terminfo
termcap. :q
$TERM
.
[new file], ,
.
( UNIX ).
, , , .
480
:q , ,
( pwd UNIX). ,
( ls)
, .
vi, (
, ex).
, , vi
. vi, vi ex (:).
:
[Read only]
File is read only
Permission denied
Read only , ,
. , vi
( view, vi -R)
.
.
:
Bad file number
Block special file
Character special file
Directory
Executable
Non-ascii file
file non-ASCII
, , .
:q! , , file.
:q
:
No write since last change (:quit! overrides).
. vi
:q!. , ,
.
File exists
File file exists - use w!
[Existing file]
File is read only
481
:w! file, , :w
newfile .
, .
Permission denied.
:w newfile .
,
mv. , :w
pathname/file, ,
(, /tmp).
, ,
, .
:!rm junkfile () ,
( ex
, UNIX).
:!df ,
. ,
, :w pathname. (df UNIX,
.)
open mode ,
.
vi. :!ls /tmp,
,
1. ,
UNIX,
UNIX.
:sh. vi CTRL-D
exit. ( UNIX
CTRL-Z
vi UNIX.
vi fg.)
:w!.
, ,
.
:pre ( :preserve). ,
. :sh ( CTRL-Z,
) vi
. vi CTRL-D ( fg),
:w!.
vi /usr/tmp, /var/tmp
. , , ,
.
482
vi ex:
Q vi ex. ex,
vi vi.
vi
,
.
, j, J.
, CAPS LOCK. vi
, (I, A, J, ..)
(i, a, j). CAPS LOCK ,
, .
, ESC,
. U
, u
. ,
, .
.
- , u
(, dd). ,
, u
. , U
- .
p, vi
. ,
, ,
:
"3p
3
. , .
.
, u ,
p. , .
D
D.
vi
, vi .
.
1980 UNIX, vi
UNIX-.
vi UNIX, , ,
. , ,
, .
vi,
.
,
. URL, ,
, .
, Tips elvis
-, vi ( ). ,
Usenet comp.editors.
- vi
-, vi: vi Lovers Home
Page . (Thomer M. Gil) Vi Pages (Sven
Guckes).
, vi.
484
Vi Pages
Vi Pages http://www.vi-editor.org.
:
vi.
.
, vi
(, , URL).
FAQ.
vi. ,
.
, vi.
vi Lovers Home Page
vi , , ,
. .
vi Powered!
vi Powered (.D.1). GIF,
-, ,
vi.
.D.1. vi Powered!
vi
485
vi Powered,
(Antonio Valle), http://www.abast.es/~avelle/vi.html.
.
http://www.darryl.com/vi.shtml,
http://www.darryl.com/addlogo.html.
,
:
1. . http://www.darryl.com/vipower.gif
.
, wget.
2. -
:
<A HREF="http://www.darryl.com/vi.html">
<IMG SRC="vipower.gif">
</A>
vi Powered!. <IMG>
ALT="This Web Page is vi Powered"
.
3. <HEAD> - :
<META name="editor" content="/usr/bin/vi">
WYSIWYG troff, -
HTML vi.
vi Powered! .
Vim http://
www.vim.org/logos.php. Vim Powered!
- http://www.vim.org/buttons.php.
vi Java
, Java, ,
1.
vi
C++, troff
-, , .
vi!
vi,
-.
1
: Java Sun
Microsystems, -
(Bill Joy) vi.
486
, , ,
vi http://www.cafepress.com/geekcheat/366808.
Online- vi
-
vi. , -
Unix World
(Walter Zintz). http://
www.networkcomputing.com/unixworld/tutorial/009/009.html (
. , vi
, URL ,
2011). :
g (global)
( set, tags EXINIT .exrc)
r R
-, ,
, .
, ,
!
vi
.D.2 D.9 vigor, vi.
vigor http://vigor.sourceforge.net.
!
, vi
FTP- alf.uib.no.
ftp://afl.uib.no/pub/vi. ,
ftp://ftp.uu.net/pub/text-processing/vi1. INDEX
, .
1
, ,
FTP , -.
487
vi
, 1995.
vi ,
.
:
docs
vi comp.editors.
macros
vi.
comp.editors
comp.editors.
programs
vi (
). ,
.
,
,
-
LINUX.
, ,
?
,
UNIX,
.
PICO
"PICO-CHU".
.
.
" !"
,
.
.
.
.
http://www.userfriendly.org/
U S E R F R I E N D LY b y I l l i a d
.D.2. vigor I
,
.
,
UNIX
.
, .
http://www.userfriendly.org/
U S E R F R I E N D LY b y I l l i a d
.D.3. vigor II
.
.
488
,
"
UNIX"?
"-"
VI. ,
.
?
,
?
!
"VIGOR"!
!
.
,
.
.
http://www.userfriendly.org/
U S E R F R I E N D LY b y I l l i a d
, ,
?
"VIGOR"
.
! ,
,
UNIX!
!
EMACS!
http://www.userfriendly.org/
U S E R F R I E N D LY b y I l l i a d
.D.5. vigor IV
489
vi
,
MICROSOFT WORD....
..., ,
-
-.
.
?
,
.
, .
http://www.userfriendly.org/
U S E R F R I E N D LY b y I l l i a d
.D.6. vigor V
?
-
"VIGOR"?
?
?
http://www.userfriendly.org/
U S E R F R I E N D LY b y I l l i a d
,
?
. ,
""?
.D.7. vigor VI
hanoi.Z
, vi:
, .
;
.
.
turing.tar.Z
vi
! ,
.
, ,
perl RCS.
490
,
VIGOR!
.
http://www.userfriendly.org/
U S E R F R I E N D LY b y I l l i a d
, !
,
,
,
.
!
!
YEAH!
OD!!
BLO
......
KILL!
,
!
FDI
SK!
...
.
-
-
http://www.userfriendly.org/
U S E R F R I E N D LY b y I l l i a d
.
,
.
"".
...
, vi
"
"
"
"
"
"
"
"
"
"
"
"
"
, !
vi
491
492
1
vi is [[13~^[[15~^[[15~^[[19~^[[18~^ a
muk[^[[29~^[[34~^[[26~^[[32~^ch better editor than this emacs. Iknow
I^[[14~'ll get flamed for this but the truth has to be
said. ^[[D^[[D^[[D^[[D ^[[D^[^[[D^[[D^[[B^
exit ^X^C quit :x :wq dang it :w:w:w :x ^C^C^Z^D
(Jesper Lauridsen) alt.religion.emacs
vi UNIX, , ,
, UNIX
vi Emacs2.
, comp.editors
( ) (.D.10
).
-, .
.
vi:
UNIX.
,
.
.
.
(
).
, Emacs.
, vi , Emacs.
, 10 .
,
, ,
, ,
, ,
,
.
, ,
. ( , BSD System V,
POSIX. System V, BSD . )
493
vi
. .
,
EMACS , VI.
?
http://www.userfriendly.org/
U S E R F R I E N D LY b y J . D . " I l l i a d " F r a z e r
.
-
,
"EMACS
-
VI?"
EMACS.
"EMACS VS VI"?
.D.10. . !
. -,
Emacs:
GNU Emacs Xemacs, GNU Emacs.
, 1.
-, GNU Emacs vi, ,
, . viper
vi.
Emacs .
, ,
.
, . vi
.
vi
, vi (
(Bram Moolenaar), Vim):
: vi
: VI 6 .
1, 2 3. 1+2+3=6. 6
. , vi .
(Arthur Tateishi)
, vi!
494
. (Nathan T. Oelger):
Vim? VIM
, : (1000(5+1))=994, , ,
2*496+2. 496 1, 2, 4, 8, 16, 31, 62, 124 248, 1+2+4+8+16+
31+62+124+248=496. 496 .
, Vim , vi,
.
, Vim , .
, ,
vi:
vi . vi . . ,
. .
(Satish Reddy)
$ ( )
, 36, 58
, 95
(ex),
80
\1, \2, ... , 99, 200
& ()
, 101
, 99
' ()
'' ( ), , 65, 73
, 73
(vile), 406
| ( )
, , 348
, , 152
ex, 83
\|, , 198
, 279
! ( )
cinkeys, , 288
, , 217
UNIX, 121, 122, 123
, 85
, 132
: ()
:!, , 121
ex , 24, 77
, 27
- ()
(ex), 81
, 34, 58
, ()
(ex), 77, 79
, 63
* ()
cinkeys, , 288
, 95
? ( )
\?, , 366
, 61
, 153
( )
, , 217
, 279
+ ( ), 422
\+, , 198, 366
, , 217
(ex), 81
vi, 68
, 34, 58
, 153
% ( )
, , 217
(ex), 92
, 89
(ex),
80
, 146
= ( )
\=, , 198, 366
, , 217
,
80
# ( )
, , 217
, 80
, , 176
, 89
^ ()
, 95
[ ] ( )
, 95
[: :], , 98
[. .], , 97
[= =], , 98
[[, ]] ( ), , 59
/ ( )
, 60
, 68
(vile), 406
( ) ( )
, , 153, 348
\(\), , 96, 200
, 131
( ) ( ), , 59
, 146
+--, , , 278
` ( )
`` ( ), , 64, 73
, 73
(vile), 406
\ ( ), , 95, 99
496
\1, \2, ... , 99, 200
\d, \D, , 399
\e, \E, , 100
\k, \K, , 199
\n, , 99
\p, \P, , 200, 399
\s, \S, , 399
\u \l, , 100
\U \L, , 100
\w, \W, , 399
\?, , 399
\+, , 198, 366, 399
\=, , 198
\|, , 366, 399
\(\), , 399
-?, (elvis), 356
-?, (vile), 384
+?, , 422
+/, , 422
_ (),
, 26
~~ (), , 280
@ ( at)
\@, , 366
@, (vile), 384, 386
@-, 136
~ ()
:~ (
), (ex), 101
, 42
, 99, 200
, 281
. ()
echo, , 230
undo/redo (nvi), 351
, 95
, 48, 93
(ex), 80
; ( )
(ex), 83
, 63
< > ( )
<< (/ heredoc),
, 140
>> (/), , 86
, 146
{ } ( )
\{}, , 199, 366
{ } ( ), , 59
cinkeys, , 287
, 153, 348
, 146
, 273
0 ( ), , 36, 58
A
A1
A1
-a, (elvis), 355, 357
a, , 217
a:, Vim, 228
:ab (), (ex), 124, 440
Acme, , 21
Address search hit BOTTOM without
matching pattern, , 62
:alias, , 375
:amenu, , 260
:apropos, , 385
:ar, , 88, 441
:args, , 88, 441
ASCII-, 322
autocmd, , 238, 243, 246, 248
autoiconify, (elvis), 364
autoindent, , 284
autosave, , 71
autowrite, , 71, 120
awk, , 143
A1
A1A1
:b (buffer), , 441
b ( ), , 36
B ( ), , 36
-b, , 321, 422
\b, , 200
b:, Vim, 228
background, color, 308
backupcopy, , 328
backupdir, , 328
backupnext, , 328
backupskip, , 328
Bad file number, , 28
Bad termcap entry, , 27
:badd, , 220
:ball, , 220
:bd (bdelete), , 441
:bdelete, , 220
:behave, (gvim), 255
:bfirst, , 220
:bg (hide window), (nvi), 347
binary, (elvis), 370
:bind-key, , 411
blank, ( sessionoptions), 335
:blast, , 220
blinktime, (elvis), 364
Block device required, , 27
Block special file, , 28
:bmod, , 220
:bnext, , 220
:bNext, , 220
:bprevious, , 220
:browse, , 369
bs, ( lptype), 379
bufdisplay, (elvis), 378
bufdo, , 220
BufEnter, , 208
:buffers, , 217, 220, 441
buffers, ( sessionoptions), 335
BufLeave, , 208
BufNewFile, , 237
B1
B1
B1
B1
497
BufRead, , 237
BufReadPost, , 237
BufReadPre, , 237
BufWrite, , 237
BufWritePre, , 237
:bunload, , 220
C1
C1
C1
C1
elvis, , 367
nvi, , 351
Solaris vi, 148, 157
vile, , 401
CTRL-,
CTRL-@, 49
CTRL-^, , 89
CTRL-] ( ), 157, 350, 368, 401
CTRL-A CTRL-] ( ; vile), 401
CTRL-B, CTRL-F (), 56
CTRL-D, CTRL-U (), 56
CTRL-E, CTRL-Y (), 56
CTRL-G ( ), 64,
80
CTRL-T ( ), 350, 368
CTRL-T CTRL-X CTRL-] ( ;
vile), 401
CTRL-V, 127
CTRL-V, ( elvis),
370
CTRL-W,
nvi,
, 348
elvis vi,
360
CTRL-X CTRL-R, CTRL-X CTRL-L
(, vile), 164
CTRL-X CTRL-S, CTRL-X CTRL-R (,
vile), 162
, 294
, 214
, , 210
curdir, ( sessionoptions), 335
CursorMoved, , 237, 238
CursorMovedI, , 237, 238
cw (change word), , 432
Cygwin, 297
d (), , 37, 43
db, d$, d0, , 44
dd, , 43, 44
de dE, , 44
df, , 64
dw, , 43
, 48, 72
, 45
, 71
, 53, 67
D (), , 44
:d (), (ex), 78
-d, , 422
-D, , 422
d$, , 432
date, (UNIX), 121
dav, 325
dd ( ), , 281, 432
:delete, (ex), 78
:delete-other-windows, (vile), 388
:delete-window, (vile), 388
:describe-function, (vile), 385
D1
D1
D1
D1
498
:describe-key, (vile), 385
df, , 30, 64, 432
dG, , 432
di (display),
elvis, , 377
nvi, , 347, 350
dictionary, , 297
diff, , 203, 330
diff, , , 274
directory, , 218
Directory, , 28
Disk quota has been reached, , 31
:display mode, , 376
:display syntax, (elvis), 372
dL, , 432
dn, , 432
dt, , 432
dumb, ( lptype), 379
dw, , 432
d^, , 432
d}, , 432
e ( ), , 59
:e, , 434
:e ( ), (ex), 89, 443
:e!, , 89
\e, , 100, 200
\E, , 100
-e, , 422
:e! ENTER, , 29
eadirection, , 207, 215
easy gvim (MS Windows), 251
echo, , 227
Eclipse, 272
edcompatible, , 101
ed, , 21
ed, , 22
:edit, , 217
Edit, (nvi),
nvi, , 347
else, , 226
elseif, , 226
elvis ( vi), 344, 354
set, , , 464
, 162
, 380
, 355
, 161
, 356
, 374
, 380
, 163
, 366
, 126
, 167
, 366
, 378
elvis.arf, , 378, 379
elvis.awf, , 380
elvis.brf, , 370, 379
E1
E1
E1
E1
elvis.bwf, , 379
elvis.ini, , 357
elvis.msg, , 357, 374
elvisexhistory, , 366
elvispath, (elvis), 357
ELVISPATH, (elvis),
357
Emacs, , 21, 251
vile, , 410
vi, , 492
END, , , 134
epson, ( lptype), 379
equalalways, , 207, 215
:er, errlist (elvis), 371
errorformat, , 318
ESC , 33
/etc/vi.exrc, (nvi), 346
:eval, (elvis), 375
ex,
UNIX, 121
, 479
, 480
, 302
ex, , 137
ex, , 21
ex, , 22, 75
, 138
, 137
ex vi, 24
, 440
, 438
, 122
Executable, , 28
execute, , 230
EXINIT, , 117
elvis, , 357
nvi, , 346
[Existing file], , 30
exists(), , 241
expr, , , 274
exrc, , 119, 346, 357
.exrc, , 117, 119, 346, 438
(elvis), 375
Exuberant ctags, , 154, 351
:exusage, (nvi), 345
E1
E1
f ( ), , 63
F ( ), , 63
-f, (elvis), 355
-F, , 344
:f (file), , 443
File exists, , 30
File is read only, , 27, 30
File system is full, , 30
File to load, , 364
filec, (nvi), 349
:files, , 217, 220
FileType, , 237
:find-file, (vile), 388
First address exceeds second, , 82
F1
F1
499
firstx, firsty, (elvis), 364
fold, , 443
foldc, , 443
foldcolumn, , 281
foldenable, , 283
foldlevel. , 282
foldo, , 444
folds, ( sessionoptions), 335
for, , 138
Fred Fish disk, 172
FreeBSD, 297
FTP, 325
function, (elvis), 372
function...endfunction, , 231
G1
G1
G1
G1
G1
.gvimrc, , 252
colorscheme, , 225
, 236
, , 232
gzip, , 168
g~w, , 432
G1
H (), , 57
-h, , 422
vile, , 384
h ( ), , 34, 58
h, , 217
help, 384
:help, , 217, 218
help, , 218
help, ( sessionoptions), 335
--help, , 206
hex, (elvis), 370, 376
hid (hide), , 444
highlight, , 309
:historical-buffer, (vile), 389
[History], (vile), 400
HOME, , , 134
$HOME/.nexrc, (nvi), 346
horizscroll, , 163
hp, ( lptype), 379
HTML, 329
html, (elvis), 368, 376
H1
H1
H1
H1
H1H1
H1
I1
I1
I1
500
K
k ( ), , 34, 58
keyword, (elvis), 372
K1
L (), , 57
l ( ), , 34, 58
\l, , 100
\L, , 100
-l, , 423
-L, , 423
l:, Vim, , 228
:last, (elvis, Vim), , 88
LaTeX, , 23
leftright, (nvi), 163, 352
:let, , 241
linewrap, (vile), 163
Linux, Vim , 178
:loadview, , 274
localoptions, ( sessionoptions),
335
lpcolor, (elvis), 378
lpcolumns, (elvis), 378
lpcontrast, (elvis), 378
lpconvert, (elvis), 378
lpcrlf, lpc, (elvis), 378
lpformfeed, lpff, (elvis), 378
lplines, (elvis), 378
lpoptions, lpopt, (elvis), 378
lpout, lpo, (elvis), 378
:lpr, (elvis), 378
lprows, (elvis), 378
lptype, (elvis), 378
lpwrap, lpw, (elvis), 378
:ls, , 217, 220
L1
L1L1
L1
L1
L1
m ( ), , 73
M (), , 57
-m, , 423
-M, , 423
:m (), (ex), 78
Mac OS X, Vim, 177, 183
magic, , 120
Make, (elvis), 363
:make, (elvis), 363, 371, 372
make, , 315
makeprg, , 318
elvis, , 371
man, (elvis), 376
manual, , , 274
:map, (ex), 126, 445
.exrc-, 119
, 129
marker, , , 275
:menu, , 260, 266, 270
mini-hilite, (vile), 400
mksession, , 334
:mkview, , 274
modeline, , 321
:modeline-format, (vile), 417
M1
M1
M1
M1
Mortice Kern Systems, 143
:move, (ex), 78
:move-next-window-down, (vile), 388
:move-next-window-up, (vile), 388
:move-window-left, (vile), 388
:move-window-right, (vile), 388
MS Windows, gvim, 251, 269
$MYGVIMRC, , 253
:n ( ), (ex), 88
n ( ), , 61, 93
N ( ), , 61
n, , (mouse, ), 254
\n, , 200
-n, , 423
-N, , 423
vile, , 384
:new, , 208, 358, 435, 446
[new file], , 27
NEXINIT, , 346
.nexrc, (nvi), 346
:Next, (nvi), 347
:next-tag, (vile), 401
:next-window, (vile), 388
noexpandtab, , 321
noh, , 447
noignorecase, , 120
nolinewrap, (vile), 405
nomagic, , 120
:no (:normal), (elvis), 376, 377
Non-ascii file, , 28
nonu (nonumber), , 80
--noplugin, , 423
normal, (elvis), 376
Not a typewriter, , 27
No Toolkit, , 389
No write since last change, , 28, 84
notagstack, (elvis), 368
nowrap, , 336
elvis, , 370
nowrapscan, , 62, 120
nroff, , 23
nu, , 36, 447
num, , 432
nvi ( vi), , 343
set, , , 462
, 161
-, 345
, 346
, 352
, 346
, 353
, 163
, 126
, 350
N1
N1
N1
N1
N1N1
N1
o ( ), , 50, 431
O ( ), , 50, 431
-o, , 423
elvis, , 355
O1
O1
501
-O, , 423
:only[!], , 224
options, ( sessionoptions), 335
other, (elvis), 373
O1
O1
:p (), (ex), 90
p (), , 37, 45, 46, 47
, 48, 72, 89
P (), , 46
, 48, 72, 89
:p (print), (ex), 76, 448
PAGE UP, PAGE DOWN, , , 134
pana, ( lptype), 379
:paste-from-clipboard, (xvile), 395
PATH, ,
Vim, 177
Pattern not found, , 60
Permission denied, , 27, 30
pin-tagstack, (vile), 402
:pop (:po), , 367, 401
:position-window, (vile), 388
POSIX, , 173
:pre, , 447
ex, 31, 70
prep, (elvis), 373
prev, , 448
:Previous, (nvi), 347
:previous-window, (vile), 388
ps, ps2, ( lptype), 379
:pu (put), , 448
P1
P1
R1
R1
R1
R1
rec, , 449
red, , 449
res, , 449
:resize, , 214, 215, 347
resize, ( sessionoptions), 335
:resize-window, (vile), 388
:restore-window, (vile), 388
:reverse-incremental-search, (vile),
405
rew, , 449
:rew, :rewind, (ex), 88
rm, UNIX, 30
ruler, , 164
S1
S1
S1
S1
S1
502
shiftwidth, ,
282
shmode, (; vile), 413
:show-commands, (vile), 385
:show-history, (vile), 400
showmode, , 164
:show-tagstack, (vile), 401
:shrink-window, (vile), 389
sidescroll, , 163, 370
sidescroll, (nvi), 352
sidescrolloff, , 337
:skeyword, , 199, 200
slash, ( sessionoptions), 335
:slast (:sl), (elvis), 359
smartindent, , 284
sn, , 450
:snew (:sne), (elvis), 358
:sNext (:sN), (elvis), 359
:so, (ex), 120
Solaris vi
set, , , 458
, 126
, 148
sort, (UNIX), 121
sp, , 451
Split, (elvis), 363
:split, , 205, 207, 217, 358, 387
:split-current-window, (vile), 387, 389
spr, , 451
:srewind (:sre), (elvis), 359
st, , 451
:stack (:stac), (elvis), 367
:stag (:sta), (elvis), 359
:stag[!], , 221
statusline, , 232
stevie, , 172, 354
stopshell, (elvis), 364
strftime( ), , 227
string, (elvis), 373
sts, , 303
stty, , 24, 25
su, , 452
substitute (:s), (ex)
vile, , 412
:sunhide, , 220
sv, , 452
:sview, , 208
:syntax, , 305
syntax, , , 274
syntax, (elvis), 376
:t (), (ex), 78
t ( ), , 63
T ( ), , 63
^T, , 304
\t, , 200
-t, , 424
elvis, , 356
nvi, , 345
vile, , 384
T1
T1
T1
T1
T1
-T, , 424
t:, Vim, , 228
ta, tag, (nvi), 350
:Ta, Tag, (nvi), 350
:ta, tag (Solaris vi), 157
<TAB>, , 262
:tabclose, , 222
:tabnew, , 222
:tabonly, , 222
tabpages, ( sessionoptions),
336
tag, (:ta),
elvis, , 367
vile, , 401
:tag, , 147, 157, 368
tagignorecase, (vile), 402
taglength, , 351
elvis, , 368
Solaris vi, 158
vile, , 402
:tagp, tagpop (nvi), 350
tagpath,
elvis, , 368
tagprg, (elvis), 369
tagrelative, (vile), 402
tags,
elvis, , 368
nvi, , 350
vile, , 402
tags, , 155, 351
tagstack,
elvis, , 368
:tagt, tagtop (nvi), 350
tagword, (vile), 402
TERM, , 25, 27
, 479
termcap, , 24
termcap, , 25
Termcap entry too long, , 27
terminfo, , 24
terminfo, , 25
TeX, , 23
tex, (elvis), 376
textwidth, , 321
thesaurus, , 297
tl, (taglength),
Solaris vi, 158
:tmenu, , 268
/tmp ( , nvi), 353
:toggle-buffer-list, (vile), 389
TOhtml, , 329
toolbar, , 270
:topleft, , 208
troff
, 23
, 130
(), 128
(), 141
T1
T1
T1
T1
503
:tselect, , 221, 303, 304
u (), , 45, 49
, 72
U (), , 45
-U gvimrc, , 270
\u, , 100
\U, , 100
-u, , 424
u, , 217
undolevels, , 332
elvis, , 369
undolimit, (vile), 402
:unhide, , 220
UNIX
Vim, , 178
, 121
unix, ( sessionoptions), 336
unm, , 453
/usr/tmp, , 30
U
U1
U1
U1
U1
U1
U1U1
U1
-v, , 424
vile, , 384
-V, , 424
-V, (elvis), 356
v, V, ( elvis), 370
v:, Vim, , 229
v:fname_in, , 331
v:fname_new, , 331
v:fname_out, , 331
/var/tmp, , 30
variable, (elvis), 373
:version, , 177
--version, , 424
:vertical, , 216
:vi, , 78, 425
vi, (UNIX)
, 68
vi,
, 117
, 122
vi.exrc, (nvi), 346
view, (UNIX), 70
:view-file, (vile), 389
vile ( vi), 71, 382
set, , , 472
, 161
-, 384
, 410
, 163
, 398
, 126
VILEINIT, (vile), 386
.vilemenu, , 386, 395
VILE_HELP_FILE,
(vile), 386
VILE_STARTUP_FILE, (vile), 386
V1
V1
V1
V1
V1
V1
V1
V1
V1
w ( ), , 36
W ( ), , 36
:w (), , 70, 88
:w (), (ex), 30, 84
:w!, , 85
, 85
, 85
^W,
, , 210
^W, , 205
-w, , 424
nvi, , 345
-W, , 425
w:, Vim, , 228
w!, , 30
^Wc, , 223
^Wf, , 221
^WF, , 221
^Wg], , 221
^Wg^], , 221
^WH, , 212
^WJ, , 212
^WK, , 212
^WL, , 212
^Wo, , 224
^W^O, , 224
^Wq, , 223
^W^Q, , 223
^Wr, , 213
^W^R, , 213
^WR, , 213
^Ws, , 207
^W^S, , 207
^WS, , 207
^WT, , 212
^Wx, , 213
^W^X, , 213
^W^_, , 216
W1
W1
W1
W1
W1
W1W1
W1
W1
W1
W1
W1
W1
W1
W1
W1
W1
W1
W1
W1
W1
W1
W1
W1
504
^W^], , 221
^W_, , 216
^W-, , 216
^W], , 221
^W+, , 216
^W<, , 216
^W=, , 216
^W>, , 216
^W|, , 216
windo, , 219
window, , 118
:window (:wi), (elvis), 359
Windows, , vile, 416
WinEnter, , 237
winheight, , 205, 215
WinLeave, , 237
winminheight, , 216
winminwidth, , 216
winpos, ( sessionoptions), 336
winsize, ( sessionoptions), 336
winvile, , 396
winwidth, , 205, 215
wm (wrapmargin), , 35, 120
, 131
, 49
:wq, , 29
:wquit, (elvis), 359
wrap, , 336
elvis, , 163
wrapmargin (wm), , 35, 120, 321
, 131
, 49
wrapscan, , 62, 69, 120
writebackup, , 328
write-hook, (vile), 416
W1
W1
W1
W1W1
W1
W1
W1
W1
x ( ), , 45, 433
X ( ), , 45, 433
:x ( ), (ex), 84, 425
-x, , 425
X, elvis, 365
X Window System, 21
gvim, 252, 269
X11,
elvis, 357, 360, 364
vile, 389
XEmacs, , 21
xscrollbar, (elvis), 365
xvile, , 390
XVILE_MENU, (vile),
386
X1
X1
X1
X1
Y ( ), , 47, 433
y (), , 37, 47
yy, , 47
, 48, 72
, 47
, 53, 67
y (), (ex), 90
Y1Y1
Y1
-y, , 425
y$, , 433
ye, , 433
yw, , 433
yy, , 433
Y1
z, , 56
-Z, , 425
za, , 276
zA, , 275
zc, , 276, 280, 281
zC, , 275
zd, , 276
zD, , 275
zE, , 275, 283
zf, , 275
zi, , 276
zj, , 276
zk, , 276
zm, , 276, 282
zM, , 275
zn, , 276
zN, , 276
z, , 281
zo, , 276
zO, , 276
zr, , 276, 282
ZZ, , 434
ZZ, vi, 28
Z1
Z1
, 59
, 59
, 79
, 26
, 293
, 176
, 160, 161
, 237
, 198, 348, 366
.exrc-, 119
vi (FTP), 486
(), 111
, elvis, 375
, 162
nvi, , 351
()
elvis, , 370
vile, , 405
, 49, 131, 161
, Windows, 269
, 25, 71
autosave autowrite, , 71
, 217
, 70
(), 200
505
, 136
, 48, 71, 89
(nvi), 353
, 219, 366
, 74
,
86
, 151, 203
/
, 45, 71
(ex), 85
, 70
, 218
- vi, 483
, 332
()
elvis, , 370
vile, , 405
, 254
, 482
, , 222
, 274
, 248
, 45, 71
, 96
, 37, 50
a (), , 37, 39
, 33
, 48, 72, 89
CTRL-@, 49
, 49, 131, 161
, --,
47
, --, 46
(elvis), 375
(UNIX), , 121
xvile, 394
vi, , 87
, 247
--, 37, 45
Vim , 202
, 29
ex (vi), 78
vi, 28, 84
elvis, , 370
nvi, , 352
vile, , 405
(GUI),
175
vi, 152
( ), 307
, , 161
elvis, , 370
nvi, , 352
vile, , 403
, , 320
(-)
(ex), 81
, 58
, 79, 83
, 322
, 152
, 37, 39
, 72
, 86
elvis, , 356
nvi, , 345
vile, , 384
heredoc, 140
elvis, , 366
nvi, , 349
vile, , 400
, 24
, , 42
(C), 300
, , 73
, 37, 39
, 91
, 98
, 92
, 101
, 41
, 40
, 40
, 62
termcap terminfo, 117
autosave autowrite, , 71
, 70
vi, , 68
, 136
($)
, 36, 58
, 95
(ex),
80
, 39
506
(+)
(ex), 81
vi, 68
, 58
, 153, 348
(%)
(ex), 92
, , 176
, 89
(ex),
80
, 146
(=),
, 80
(#)
, 80
, , 176
, 89
() , 37
, 91
, 98
, 92
, 101
, 41
, 40
, 40
, 62
, 48, 71, 89
, 136
nvi, , 346
vile, , 386
Vim, 175
, 162
nvi, , 352
vile, , 404
, , 272
(IDE), 272
, vi , 483
vi, 152
elvis, , 360
, , 160
elvis, , 366
vile, , 400
, ,
253
, , 143
, 147, 154
, 143
, 146
(XXX_DQUOTE), , 72
(^)
, 58
, 95
, , 326
([ ])
, 95
[. .], , 97
[= =], , 98
[[, ]] ( ), , 59
, 146
backspace
, 34
, 33
Caps Lock, 52
Enter
, 35
, 34, 58
ESC, , , 28
:map,
126
, 129
, 133
, 97
, 98
vi, 149
GUI-
elvis, , 360, 372
vile, , 389
set, , , 458
, 152
, 151
nvi, , 346
elvis, , 371
vile, , 407
elvis, , 366
nvi, , 348
vile, , 398
Vim, , 198
, 167
, 160
, 154
, , 293
, 22
vi (UNIX)
, 87
, 203
, 68, 422
elvis, , 355
nvi, , 344
vile, , 383
, 189
, 421
, 22, 23, 28, 32, 425
gvim, , 253
, 164
, 126
, 129
, 133
, 22, 482
cw, , 23
ex, 29
507
execute, 230
i (), 23
wq, , 29
w!, , 30
w, , 29
, 242
, 243
.exrc , 119
, 24
, 431
, 294
, 428
(Vim), 434
Vim, 338
, 124
, 427
ex, 29, 76
, 76, 79
, 79
, 81
, 82
, 80
, 79
, 28, 84
, 83
vi, 32
vi, 68
, 41
, 35, 51
ex, 142
(), 131
elvis, , 371
, 287
- , 93
Vim, 175
, 144
gvim, 252
, , 25
, 37, 47
, 48, 72, 89
, 47
--, 37
, 78
, 86
vi, 485
( )
\(\), , 200
..., 96
, 131
( ) ( ), , 59
, 146
, 34
, , 33, 57
xvile, , 394
, 65
, 68
, 60
, 73
, 59
vi Powered, 484
.exrc-, 119, 120, 346
, 436
(Vim), 235
Windows, 255
gvim, 255, 258
, 263
xvile, 395
, 176
, 94
nvi, , 348
Vim, , 198
( vile), 406
elvis, , 358
vile, , 387
, 203
, (Moolenaar, Bram), 171, 493
, (Morgan, Clark), 382
, 117
-ASCII , 322
, 35
, 76
, 59
, 44
, 36
ex, 76
, 79
, 81
, 82
, 64, 80
, 64
, 80
(gvim), 254
/
, 45, 71
(#), 89
(%), 89
(`)
, 73
`` ( ), , 64, 73
(\), , 95
\u \l, , 100
, 61
, 52
, 280
508
, 206
, , 223
, 213
, , 209
, 211
, 206
-
nvi, , 345
vile, , 384
vi, 486
set, , 117
, 118
vi, 68
(ex),
, 117
, 68
, 87
, 89
, 70
(elvis), 374
, 49
( vi), 162
elvis, , 369
nvi, , 351
vile, , 402
, 72
, 45
, 332
(ex), 81
, 26
, 24
, 126
, 132
, , 136
, 129
, 133
, , 314
, 266
elvis, 363
(ex), 85
, 228
, 240
,
Vim, 234
, 246
, 88
(), 111
/
, 46
, 78
(--), 37
, 103
, 34, 57
, 65
, 68
, 60
, 73
, 36, 59
vile, 416
, 60, 62
, 57
(), 111
, 46
, 47
(vile), 416
, Vim, 176
, 76
elvis, , 362
gvim, 253
, 48
, 101
, 72
, 61, 63
:g, 113
elvis, , 374
nvi, , 352
, 165, 272
, 147, 154
,
, 147, 154
, 143
, 146
, 166
elvis, , 376
Vim, 174
-, 165
elvis, , 371
vile, , 407
, 166, 305
elvis, , 408
, 372
, 306
(:s), (ex), 77, 91
- , 93
, 98
, 95
, 102
, 101
, 92
, 72
, 95
, vile, 407
, 60
, 63
, 98
, 95
509
, 102
, 101
, 117
( vi), 162
, , 120
, 68
, 60, 62
, 146
ex , 81, 83
gvim, 257
xvile, 393
, vile, , 417
, 49
, 35
(), 127, 129
, 73
, 64
(ex), 80
(Vim), 176
, , (elvis), 357,
379
, , 35
, 59
, 59
, , (elvis), 357,
379
, , 89
, 42
, 26
, , 144
, 26
, 23
, 176
, 56
elvis, , 370
nvi, , 352
vile, , 405
, 56
, , 100
, vile, 415
, 26
, , 59
, 28, 30
, 247
elvis, , 366
vile, , 398
Vim, , 198
, , 351, 368
, , 42, 100
, 176
, 94
nvi, , 348
Vim, , 198
, 95
, 98
, 101
, 102
ex, , 160
elvis, , 366
nvi, , 349
vile, , 411
, 70
ex, 78
, 151
, 147, 154
, 144
, 146
, 432
, 117
, 87
, 69
, 130
vi, 349, 366, 400
, 28
, 22, 28, 426
gvim, , 253
, 164
, 132
, 124
(gvim), 254
, 42
, 273
, elvis, 372, 376
, 281
, 28
, 27
, 69
, 328
, 276
, 273
(Vim), 202
, 28
, 35, 161
() , 41
` (vile), 406
, 34
, 46
, 63
, 33
, 100
Vim, 174
, 283
, xvile , 395
, , 70
ex, 137
510
Vim, 175, 225
, 218
, 53
(), 40
, 45
, 36
, 47
, 103
, 126, 127, 129
,
130
(), 131
, 56
, 146
, 124, 338
, 124
(),
141
, 124
, 84, 434
, 86
, 70
, 85
, 130
, 218
, , 57
POSIX, 173
, 157, 302
elvis, , 367
nvi, , 350
Solaris vi, 148, 157
vile, , 401
(), 39
, 47
' (vile), 406
, 52
, 131, 161
, 68
, 45
, , 118
, 35
, 58
, 64
, 76
, 63
, 42
C/C++
(), 131
:g, 114
, 60
, 21
, , 42, 100
, , , 221
, 50
, 28
, 49, 131,
161
, , 91
(), 37, 39, 62
, 144
(--), 37,
47
(), 131
, 45
(), 111
(--), 37
, 46
, 100
, 37, 64
, 48, 72, 89
, 71
, 71
ex, 81
, 45
, 33
, 43
, 164
, 83
, 36, 59
, 103
, 141
, 85
, 21
ex, 78
(ex)
, 82
. , 80
(~)
, 26
, 97
, 42
, 99
:~ (
), (ex), 101
, 27
(.)
, 26
, , 176
, 95
, 48, 93
(ex), 80
(;)
(ex), 83
, 63
, 71
(), 131
, 78
, 37, 43, 64
, 48, 72, 89
, 45, 71
ex, 81
511
, 33
, 43
, 44
, , 154
, 284
, 226
, , 45
, elvis, 356
, 434
ex , 137
, 26, 76
, 86
, 203
vi, , 120
, 26
, 68
, 87
, 89
, 70
(ex), 85
, 479
, 236
, 324
, 311
(. ), 480
(% #), 89
, 30
, 130
({})
, 153
, 146
, , 85
strftime, 227
, 231
, ,
133
GUI-, 360
, 225
, 138
vi, 493
, 35, 51
, 52, 100
, 120
, 117
, elvis, 362
, 21
, 151
, 57
, 56
, 56
, , 118
1995
.
,
.
: OReilly, Pearson Education, NewRiders,
Addison Wesley, Wiley, McGrawHill, No Starch Press, Packt, Dorset
House, Apress .
, , .
:
:
. . 16 , . 7 (. ),
. (812) 380-5007
:
. 2- , . 14
(. /),
. (495) 6385305
http://www.symbol.ru
.
www.symbo l . r u
,
.
, , www.symbol.ru.
. !