edit |
insert at cursor Insert at start append after cursor Append to line |
x kill char X kill back delete/cut text dobj - dw, d$, etc. dd clears whole line D to end of line change - cobj, ciobj, cc, C |
replace one char Replace text substitute char yank/copy - yobj, yy put (paste) undo, ctrl-redo visual select . repeat edit |
---|---|---|---|
move |
end, begin word $,0 end, begin line (,) sentence ←, → {,} paragraph ←, → ctrl-back, ctrl-fwd page fA goes to next "A" tA before next "A" |
gg <C-b> H k { ( B b h l w W ) } j L <C-f> G |
/pattern → ?pattern ← next pattern * word under cursor % matching bracket mx set mark x `` go back, `x to mark |
files & windows |
:e file edit :w file write :wq write & quit :r file read into buffer :r !command - get output :sp file - in new window :q - quit buffer/window |
ctrl-w then... new split current vertical split h, j, k, l jump ← ↓ ↑ → +, -, = size current file under cursor in new window |
- - - cut or fold here - - -
style |
:set expandtab - use spaces :set shiftwidth=2 :set textwidth=70 :set nowrap |
tweak |
Join gqobj - autoformat ~ change case of char >>,<< indent, unindent = autoindent :rangesort |
---|
nctrl-a, nctrl-x - inc or dec number by n
:s/pattern/replacement/g - on this line (g for multiple)
:%s/pattern/replacement/gc - on every line but confirm
:perldo s/foo/bar/g - do Perl on every line
:.perldo s/bar/baz/g - do Perl on this line