2012-10-20

My Vim Cheat Sheet



COMMAND mode:
:ci( - replace text between brackets
:ci" - replace text between quotes
ctrl+g - see where you are
g ctrl+g - advanced where you are
`. - jum to location of last modification
dtx - deletes upto and including the next x
dftx - deletes downto the previous x
:%s/TEXT//ng - count the number of matches
:e - reload current file (similar to :edit)
:set ft=html - change filetype (for example, to indent html inside php file)
Splited views (also helpfull with NERDTree plugin):
ctrl+ww - toogle between splited views 
ctrl+wv - split vertical
ctrl+wh - split horizontal

INSERT mode:
ctrl+t - insert indent to current line
ctrl+d - delet indent to current line
ctr+y - insert chars frome above line
ctrl+e - insert chars frome below line

ctrl+x xtrl+o - omni autocomplete(ctrl+n, ctrl+p to move next/previos line in omni autocomplete)


VISUAL mode:
ctrl+v - enter VISUAL BLOCK selection mode
Adding smth to multipple lines: select VISUAL BLOCK, press "I" (capital i) type smth you want to add (it appears only in first line which were selected), hit "ESC"... tadam chars you've entered added to every line which been previously selected. BTW: instead of "I" you could type "c" - it will cut selected blocks and qfter that you could type anything you want (also helpfull to uncomment block of code)


...to be continued

Other stuff:
:cd %:p:h '  - will change the working directory to the dir for current editing file
J - will join that line and the next line together (shift+j)

Комментариев нет:

Отправить комментарий