Skip to content

miku86

Vim

Ideas

Shortcuts

:help help
:q quit
:w write
:o open
esc escape mode
i insert mode
c - change mode
v - visual mode to select chars
V - visual line mode to select lines
vim tutor to learn
hjkl - left, down, up, right
u - undo
w - next start of word
b - last start of word
e - next end of word
f - find
x - delete char
dd - delete line
yy - copy line
yw - copy word
p - paste at cursor
P - paste before cursor
ctrl + r, 0 - paste in insert mode
r - replace with
3l - 3 times l key
di( - delete inside next (
da( - delete around next (
. - repeat last action
gg - go to start of file
G - go to end of file
dw: delete next (word)
ddp: swap lines
:% s/foo/bar/g: in all lines (`%`), `s`ubstitute (= search & replace) `foo` with `bar`
:% s/foo/bar/gc: in all lines (`%`), `s`ubstitute (= search & replace) `foo` with `bar`, ask for `c`onfirmation on each occurency
:1,$ s/foo/bar/g: from line `1` to the end (`$`), `s`ubstitute (= search & replace) `foo` with `bar`
:.,$ s/foo/bar/g: from the current line to the end (`$`), `s`ubstitute (= search & replace) `foo` with `bar`
:s/foo/bar/g: in the current line, `s`ubstitute (= search & replace) `foo` with `bar`

Links

  • https://vimawesome.com/
  • https://vim-adventures.com/
  • http://www.vimgolf.com/
  • https://vim.fandom.com/wiki/Search_and_replace