Skip to content

Instantly share code, notes, and snippets.

@dimanyc
Last active July 14, 2016 15:39
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 dimanyc/127f30a7e4e9bfd725d5d7320726296a to your computer and use it in GitHub Desktop.
Save dimanyc/127f30a7e4e9bfd725d5d7320726296a to your computer and use it in GitHub Desktop.
basic VIM commands

Clipboard

v(*)"+y - will copy lines selected in Visual mode.

Folding

zfat or zfit - folds HTML by indentation?

Find / Replace:

:s%/foo/bar/g - Change each 'foo' to 'bar', (% means in every line)

Windows Resizing:

ctrl + w then [n](optional) then direction (<< or >>)

Buffer

:b# - back to previusly buffered command

Explorer

:Vexplore - vertical explorer window

Indentation

gg = G - normalizes indentation

Vim Surround

cst=[tag] - change surround tag or symbol

Navigating

h - left

j - down

k - up

l - right

Exit:

:q - discard and quit :x - save and quite. add ! (bang) to force

Deletion:

x - delete single charater d$ - delete everything follwoing the current cursor position ( to the end of the line ) dw - delete word , or everyting until the start of the next word, EXCLUDING its first character 'de' - delete everything to the end of the current word, INCLUDING the last character.

Motions with count:

(n)w- move n words forward (n)e- move to the end of the nth word foward 0 - move to the begining of the current line

Deletion with motions:

d(n)w - deletes the n numbe of words (n)dd - deletes n number of lines

Undo:

u - undoes the last commands U - undoes changes to a line Ctrl (command) + r - undoes the undos #<= wtf??

Insertion:

A - start inerting at the end of line (without replacing the last char)

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