常用的
h: left
j: down
k: up
l: right
Ctrl+d: page down
Ctrl+u: page up
b: left word
w: right word
dw: delete word
dd: delete current line
H: goto top of screen
M: goto middle of screen
L: goto bottom of screen
gg: goto first line
G: goto last line
dG: delete all
^: first char of line
$: last char of line
{n}G: jump to line n
gt: go to next tab
gT: go to previous tab
{n}gt: go to tab n
:wqa: save all tabs
:qa!: quit and don't save all tabs
vip: select a block
gg=G: reindent the entire file and convert tabs to spaces
覺得不滿意的話,可以試試 astyle(for objc)。
nmap <F9> :%!astyle -bps2 --brackets=attach --convert-tabs --mode=cs<CR>
insert mode
Ctrl+w: delete word before the cursor
Ctrl+h: backspace/delete
Ctrl+u: delete the current line before the cursor
Ctrl+o+D: delete the current line after the cursor
Ctrl+o+I: like Press Home
Ctrl+o+$: like Press End
Ctrl+o 可以看成暫時跳離 insert mode
Insert text in multiple lines
Ctrl+v
j
I
your insert text
<Esc>
Plugins
\\w
EasyAlign
自動對齊
Select a block
<Enter>
: or = or - or <space>
<F8>: toggle
Ctrl+w+w: switch panel
vimdiff
Ignoring white space for vimdiff.
.vimrc add
set diffopt+=iwhite
vimdiff file1 file2
or
vim -d file1 file2
[c: previous
]c: next
do: get changes from other window into the current window
dp: Put the changes from current window into the other window
zo: open the fold
zc: close the fold
zr: reducing folding level
zm: more folding level
zR
zM
:diffu: update the diff file.