Skip to content

Instantly share code, notes, and snippets.

@brenogcota
Created June 24, 2021 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brenogcota/d800c645ff57721b76da69ca268e1803 to your computer and use it in GitHub Desktop.
Save brenogcota/d800c645ff57721b76da69ca268e1803 to your computer and use it in GitHub Desktop.

Basics

save and quit

:wq or :x

quit

:q

force quit

:q!

back file

ctrl + o

insert mode

i

visual mode

v

undo

u

Search

search for pattern

/pattern

search pattern (regex)

\vpattern

replace all old with new throughout file

:%s/old/new/g

replace all old with new throughout file with confirmations

:%s/old/new/gc

Search in multiple files

:vim[grep] /pattern/ {{file}} - search for pattern in multiple files e.g. :vim[grep] /foo/ */

Window

split window

Ctrl + ws

quit a window

Ctrl + wq

switch windows

Ctrl + ww

Indent text

indent (move right) line one shiftwidth

">>"

de-indent (move left) line one shiftwidth

"<<"

indent a block with () or {} (cursor on brace)

">%"

indent inner block with ()

">ib"

indent a block with <> tags

">at"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment