Practical Vim 学习笔记
Apr 10, 2013
.vimrc dotfile Setting sp
set matchtime=1
let g:user_zen_expandabbr_key='<C-y>'
nnoremap <silent><C-l>: <C-u>nohlsearch<CR><C-l>
\<CR> =[enter]
####Tip1
. =repeat last change ( when over insert mode, the total edit contents are included
>G =auto indent
####Tip2
A =end of line insert
$a =the same effect above
####Tip3
s =instead of a char
; =repeat last f{char} commend
####Tip4
@: =repeat last EX commend
####Tip5
* =search the word which cursor hover over
####Tip8
u =undo last change
<C-r> =undo undo
####Tip9
daw =delete word
####Tip10
cW =modify a word (symbol will be a normal char)
180<C-x> ???
####Tip11
d2w = 2dw = dw. (but which one is the best?
####Tip12
dl =delete a char =x
dap =delete an entire paragraph
g~, gU, gu =convert char's capital and small letter
gUap =convert entire paragraph into Upper-case letter
gUgU=gUU =convert current line into Upper-case letter
=G =auto indent
####Tip13
<C-h> =delete back one char
<C-w> =delete back one word
<C-u> =delete back to start of line
####Tip14
<C-[> =back to NORMAL mode =<ESC>
zz =redraw the screen with the current line in the middle of window
####Tip15
K =looks up man page for the word under the cursor
yt, =yank the word befor , to {register}
<C-r>0 =<C-r>{register} = under INSERT mode, paste the register text
<C-r><C-p>{register} =more smarter
Tip16
<C-r>={do math}<CR> =do math for us under INSERT MODE
Tip17
ga =inspect the code for the char under the cursor
Tip19
R =engage REPLACE mode
Tip20
viw =visually select word
Tip21
v =into VISUAL mode
V =line-wise VISUAL mode
<C-v> =block-wise VISUAL mode
gv =reselect the last VISUAL mode
o =(VISUAL) redefine the bounds of the selection
Tip22
2> =(VISUAL) indent twice
Tip23
vit =select the inner contents of a tag (HTML) ->cit,dit
U =(VISUAL) convert the selected char to upper-case
gUit
Tip24
Vr- =replace every chars in VISUAL line with -
Tip25
<C-r>3je =quick VISUAL-block select
c =[VISUAL] change one word
Tip26
<C-v>$A;[Esc] =Append ; on the end of every selected line
Tip27
:$ =[EX] the end of the file
:. =[EX] the current line of the file
:% =[EX] all the lines in the current file
Tip28
:[range]copy|co|t{address} =[EX] make a copy of line{range} put it blew the {address}
:'<,'> =[VISUAL] + [EX]
<C-r>dGp =select texture move to the end of the file
Tip29
:[range]m{address} =[EX] cut of lines{range} and put it blew the {address}
Vjj :'<,'>m$ =move selected lines to the end of the file
Tip30 (=>67,69)
VG =from current line to the end of file make VISUAL select
:'<,'>normal. =for each line in the VISUAL selection, and execute . commend
:9,13normal A; =with end of the 9th~13rd line append to ;
:9,13normal i// =the 9~13lines become comments
Tip31
:bn[ext] =step forward through the buff list
:bp[revious] =backward
Tip32
:<C-d> =[EX] ask vim reveal a list of possible completation
Tip33 (=>76)
:%s//<C-r><C-w>/g =[EX] <C-r><C-w> equal mapping copies the word under the cursor
Tip34 (=>85)
q: =open the command-line window with history of EX command
q/ =open the command-line window with history of searches
Tip35 (=>44)
:!{cmd} =excute {cmd} with the shell
:shell =start a shell
:read !{cmd} =excute {cmd} in the shell and insert its standard output below the cursor
:[range]write !{cmd} = ... with [range] lines as standard input
Tip36
:ls =give us a listing of all the buffers
<C-^> =quick toggle between the current and alternate files
:bf :bl =jump to the start or end of the list
:bd =delete a buffer
Tip37
:args =open argument list
Tip38
<C-w>v | :sp {file} =split the window vertically
<C-w>s | :vsp {file} =divide the window horizontally
<C-w>w =cycle between open windows
<C-w>hjkl =switch to activate window
<C-w>o | :on =keep only the active window
Tip40
:lcd {path} =set the working dictory locally for the current window (not tab page)
:windo lcd {path} = ...all windows
:tabe {file} =open a new tab page
:{N}gt =switch to tab page number {N}
:gt =switch to the next tab page
:gT =switch to the previous tab page
:tabm {N} =rearrage tab page Number
Tip44
:!mkdir -p %:h =create nonexistent directories
Tip47
w =prev cu[r]rent [n]ext
b =prev [c]u[r]rent next
e =prev cu[r]ren[t] next
ge =pre[v] cu[r]rent next
Tip48
ea =append at the end of the current word
gea =append at the end of the previous word
Tip49
f|F|t|T{char};, =find the {char} and move to it
Tip50
d/ge<CR> =tell the d{motion} command what to delete
Tip52
ciw =delete the word without trimming any whitespace
Tip53
`` =position before the last jump within current file
Tip54
% =jump between opening and closing sets of parenthese
Tip55
<C-o> =the back button
<C-i> =the forward button
:jumps =inspect the contents of the jump list
( =jump to start of previous sentence
{ =jump to start of previous paragraph
gf =jump to the filename under cursor
<C-]> =jump to definition of keyword under the cursor
Tip56
:changes =call the change list
Tip57
:set path?
gf | <C-]> =commands provide wormholes that transport us from one part of our codebase to another
Tip58
m{letter} =create a mark at the current cursor position (L->local buff; U->Global marks)
`{letter} =back to mark
:marks =open marks' list
Tip59
xp =transport the next two char
ddp =transport the order of this line and its successor
P =paste the contents of our unnamed register in front of the cursor
Tip60
:reg =open registers' list
"{register} =call register
"_d{motion}
"+ | "* =X11 clipboard, used with cut, co, and paste
"% "# ". ": "/
Tip61
gvp =switch the paste content in VISUAL mode
Tip62
yiwciw<C-r>0<Esc> =some sequence of action make copy and paste
Tip63
q{ register } =start record a sequence of changes
@{ register } =execute the contents of register
Tip66
qq;.q22@q
Tip67
:'<,'>normal @a =tell vim to execute the MACRO once for each line in the selection
Tip68
qA =append commands to the existing contents of register a
Tip70
:let i=1 =create a variable
qaI<C-r>=<CR>)<Esc> :let i+=1 q
:'<,'>normal @a
Tip71
:put a =paste the contents of register
Tip83
/lang/e<CR>
Tip88
:s/going/rolling
:s/going/rolling/g
:%s/going/rolling/g
Tip93
/\v^([^,]*),([^,]*),([^,]*)$
:%s//\3,\2,\1
Tip99
:g/TODO/t$
Tip100
:'<,'>sort