Professional Documents
Culture Documents
vi filename :
vi +n filename n
vi + filename
vi +/pattern filename pattern
vi -r filename vi filename
vi filename....filename
h
l
space
Backspace
k Ctrl+p
j Ctrl+n
Enter
w W
b B
e E
)
(
}
{
nG n
n+ n
n- n
n$ n
H
M
L
0
$
Ctrl+u
Ctrl+d
Ctrl+f
Ctrl+b
nz n n
i
I
a
A
o
O
r
R ESC
s
S
ncw nCW
nCC
ndw ndW n-1
do
d$
ndd n-1
x Xx X
Ctrl+u
/pattern pattern
?pattern pattern
n
N
s/p1/p2/g p1 p2
n1,n2s/p1/p2/g n1 n2 p1 p2
g/p1/s//p2/g p1 p2
set
all
term
ignorance
list(Ctrl+I)$)
number
report
terse
warn NO write
nomagic \
nowrapscan vi
mesg vi write
n1,n2 co n3 n1 n2 n3
n1,n2 m n3 n1 n2 n3
n1,n2 d n1 n2
w
e filename filename
r filename filename
x
X
q vi
q! vi
!command shell command
n1,n2 w!command n1 n2
command n1n2
command
r!command command
"?nyy n ?
n
"?nyw n ?
n
"?nyl n ?
n
"?p
ndd n 1
tags
[{ "{"
}] "{"
{
} [ and ]
ctrl+t
gd
*
#
Vim Vim
---- 1
kjhl Linux
4 4 4
nG n
Ctrl+G
wb
---- 2
iar
(i=inserta=appendr=replace)
cwdw()/
(c=changed=delete)
xd$dd
---- 3
---- /string?string
---- 4
---- yyp
---- 1/etc/passwd
---- vi file
---- :r /etc/passwd file
/etc/passwd
---- :%s/:.*//g /etc/passwd
---- :3r
/etc/passwd 3 /etc/passwd
---- #
VI
-------------------------------------------------------------------------------
0
Ctrl-F
Ctrl-B
nG n
c Esc
cw
cnw n
yy
yn
ynw n
zz
:w filename
:W
:x()
:q!
:q vi
vi
1)
vi FileName FileName,
vi +n FileName FileName, n
vi + FileName FileName,
:n1,n2 co n3 n1 n2 n3
:n1,n2 m m3 n1 n2 n3
:n1,n2 d n1 n2
:n1,n2 w filename n1 n2
filename
:n1,n2 w! Command n1 n2
Command
n1 n2 Command
?([])
% ([{ }] )
) (
) [
] {
?([])
daB {} ( v )
diB {}
ab ()
ib ()( () )
aB {}
iB {}( {} )
?
()
? ctags
#ctags
-f
/usr/share/vim/vim63/funcs.tags
-R
/opt/j2sdk/src /usr/src/kernels/2.6.Array-5.EL-i686
^p
^n ~/.tags
^[ ~/.tags ,
^t
:pta
K C man
?
gd
Gd
?
:cn
:cc
:cl
3]
?
h
l
?
w W
B b
E e
?}
(
?)
{
? k Ctrl+p
j Ctrl+n
Enter
nG n
n+ n
n- n
n$ n
0
$
?
H
M
L
Ctrl+u
Ctrl+d
Ctrl+f
Ctrl+b
nz n n
4}
# ( )
:g/^/exec "s/^/".strpart(line(".")." ", 0, 4)
?
i
a
?
I
A
o
O
5)
r
R ESC
s
S
6)
ncw nCW
nCC
:r filename filename
7)
/
/
:g/str/s/str1/str2/g
g s1
g
str str1 str2
:%s/f $/for$/g f f
for
:%s/^/mv /g mv mv
xp
ddp
:g/fred/t$ fred (EOF)
Array)
:vne [filename]
:sp [filename]
:S [filename]
:new [filename]
:^w + ^r
^w =
:res -n n
:res +n n
:vert res -n
:vert res +n
10)DOS Unix
:1,$s/^M//g
11)
debug1
mdebug1 debug1
`debug1 debug1
12)
:%s/r//g DOS ^M
:%s= *$==
:%s/^(.*)n1/1$/
:%s/^.pdf/new.pdf/ pdf
:%s///
:g/^s*$/d
:g!/^dd/d dd
:v/^dd/d v == g!
:g/str1/,/str2/d str1 str2
:v/./.,/./-1join
:g/^$/,/./-j
ndw ndW n-1
d0
d$
ndd n-1
x X
Ctrl+u
^R u
J
V
^V ^V
aw
iw ()
as
is ()
ap
ip ()
D
x,y
dl x
d0
d^ TAB
dw
d3w
db
dW
dB
d7B 7
d
d4
d
d
d{
d7{ 7
dd
d/text text
dfc c
dtc c
D
d$
5dd 5
dL
dH
dG
d1G
r
cw
c3w
cb
cW
cB
c7B 7
c0
c}
c4}
c
c
c{
c7{ 7
ctc c
C
cc
5cc 5
.
13}Set
set all
set term
set ignorecase
set list (^I) ($)
set number
set showmode
set report
set terse
set warn
No write
set autowrite :n :!
set nomagic
set nowrapscan vi ,
autoprint (ap) ap
autowrite (aw) noaw :n,:!
beautify (bf) nobf (
(tab),(newline),(formfeed))
directory= (dir=) /tmp
edcompatible noedcompatible ed
hardtabs= (ht=) 8
ignore case (ic) noic
lisp nolisp lisp
list nolist
magic agic
mesg mesg
number (nu) nonumber
open open
optimize (opt) optimize ,
paragraphs= (para=) IPLPPPQPPLIbp { & }
prompt prompt :
readonly (ro) noro !
redraw noredraw
remap remap
report= 5 >
scroll 1/2 window ,
z (z 2 )
sections= SHNHH HU ( [[ ]]
)
shell= (sh=) /bin/sh SHELL,
SHELL ,
shiftwidth= (sw=) 8 (shift)
showmode noshowmode
slowopen (slow)
tabstop= (ts=) 8 (tabstop)
taglength= (tl=) 0 (0
)
tags= tag, /usr/lib/tags
term=
terse noterse
timeout (to) timeout
ttytype=
warn warn "No write since last change"
window= (w=)
wrapmargin= (wm=) 0 , 0
, n
wrapscan (ws) ws
^
ESC
^[ ESC
15]
guu
gUU
g~~
guw () iw
gUw ()
g~w ()
vEU ()
vE~ ()
ggguG ft!bt!
16) . ()(ft,
)
`.
()
:ju(mps)
17)
:history
:his c
:his s
q/
q
:
18]
# (Registers)
:reg registers
"1p register 1 1
registerp paste
" register
", register
0~Array,a~z
dd y
visual d( ) y(
)
register
register, ""
/
dd y ""
1Array}
"
[email=ayy@a]ayy@a[/email]
Vim
"ayy register a @a
register a
10yy copy 10
11}
:%!sort -u sort
"
set tags=/usr/share/vim/vim63/funcs.tags
" [Ctrl]N
set complete+=k
"
set visualbell
"
:set history=50
"
:set ruler
"
set fileencodings=gb2312
"set encoding=euc-cn
" ruler
set ruler
"
set showcmd
"incsearch
set incsearch
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
"
:filetype on
"""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""
if version >= 600
"
"map /
"
map yiw/^ ( s )* (sub ) | (function ) ( s
)*"
"
map n
"
map :Tlist
" compiler
"map :make "%"
" php
map :!php -l "%"
map ;w :call FormatText()
"
map /
endif
"""""""""""::
""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""
"""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""
function FormatText()
:%s/t/ /g "t 4
:%s/ *$//g "
endfunction
"""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""
""""""""""
tab
"""""""""""""""""""""""""""""""""""""""""""""""
set listchars=tab:>-,trail:~
set list
syntax match Trail " +$"
highlight def link Trail Todo
""""""""""::
tab
"""""""""""""""""""""""""""""""""""""""""""""
function LastMod()
if line("$") > 5
let l = 5
else
let l = line("$")
endif
exe "1," . l . "/CnsProgCMTime/s/CnsProgCMTime
.*/CnsProgCMTime " . strftime("%Y-%m-%d %H:%M:
%S")."/e"
endfunction
"map :call LastMod()
"""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""
"/* ... */ ,r * ;
"o "o" "O" *
:set formatoptions=tcro
"""""""""""::
""""""""""""""""""""""""""""""""""""""""""""""""""
vi
| home|house home house
() home|house ho(me|use)
* () (home|house)*
home,
homehouse,househome, homehousehomehouse
(...)
+
()(...)
ho(use|me)+ house home
?
free?d fred freed
(home|house)
homehome, homehouse,
househome, househouse
?
:!perl -c %
:!php -l % php
:!php -q % php
? a.out ./a.out
:!gcc % -o a.out && ./a.out
old umask is %#0
new umask is %#0
?
:cl!
:cl
:cn
:cp
:cnew
:cold
:cwin :copen
:cclose
CTRL-X CTRL-F
CTRL-X CTRL-L
CTRL-X CTRL-D ()
CTRL-X CTRL-I
CTRL-X CTRL-K
CTRL-X CTRL-T
CTRL-X CTRL-]
CTRL-X CTRL-V Vim
C
gd
gD
------------------------------------------------------------------------------------:checkpath include
------------------------------------------------------------------------------------[i
extern
__mode_t
umask
(__mode_t
__mask)
__THROW;
------------------------------------------------------------------------------------[+CTRL+i [i
-------------------------------------------------------------------------------------[I
-------------------------------------------------------------------------------------[d #define
printf(|tom);
#define tom "yaoshuyin"
------------------------------------------------------------------------------------CTRL+]
CTRL+T CTRL-]
:tselect
[/
]/
---------------------------------------------------------------[# #if, #ifdef, or #else
]# #else #endif
[( (
)) ]
[{ {
}} ]
?
ga ascii,hex,oct,...
s ga
115, Hex 73, Octal 163
I string
A string
C ( )
c ( )
> Tab
vimrc
D: cnscnprogrames Vim vim63 vi
tmp file.java ( D: cnscnprogrames Vim vim63
tmpfile.java)
expand("%") #tmpfile.java
expand("%:p") #D: cnscnprogrames Vim vim63
tmpfile.java
expand("%:h") #tmp
expand("%:t") #file.java
expand("%:e") #java
expand("%:t:r") #file
expand("%:r") #tmpfile
?
#vi ~/.vimrc
" FArray