vim tippek

vim_logo
Kis gyűjteményem, vim fejlesztői környezet hatékony használatához.

"commands
c_<C-f>              : show command history
c_<C-r><C-f>         : insert Word from current position
c_<C-r><C-a>         : insert line from current position
c_<C-f>i<C-n>        : commandline history, insert, complete word

"file managemant
:w %:h/newfile       : saveas current_dir/newfile
:sav[e] %:h/newfile  : saveas and open current_dir/newfile
gf                   : goto file under cursor

"folding
zo                   : Open the fold underneath the cursor.
zc                   : Close the fold underneath the cursor.
zC                   : Close the fold underneath the cursor
                       and all folds within that fold recursively.
zM                   : Close all folds.
zR                   : Open all folds.

"info
ctrl-g               : file info

"insert
ctrl-r – or ctrl-r " : insert current buffer in modes: i/I/a/A
gI                   : like "I", but always start in column 1
]p                   : like "p", but adjust indent to current line
["x]gp               : put the text [from register x] after the
                       cursor N times, leave the cursor after it
ctrl-k {char1} [char2]    : enter digraph, like <C-CR> <S-Space> etc.
ye (motion) ve"0p (motion back) vep   : swap two words
ye (motion) vep (motion back) vep     : swap two words

"moving
@:                   : repeat last : command (then @@)
ge                   : end of word/token left
e                    : end of word/token right

"search
"important to set path well
[I                   : find the word under the cursor in include files
[<Tab>               : to jump there (first match)

"search and replace
&                    : repeat last :s
g&                   : repeat last ":s" on all lines
:%s/class=([^" >]+)/class="1"/gc
                     :
:%s/<([hb]r|img[^>]*) />/<1>/gc
                     :
:%s/%Vold/new/gc    : only in previous selected area
                       (that would matched with gv)
:s/'[0-9-]+'/=substitute(submatch(0), 'd', '0', 'g')/g
                     : subreplace example
                       replace all d by 0 in eg.: '1-2-3'

"select
ctrl-v  (windows: ctrl-q) : visual block
v                    : visual
viw                  : select inner word

"system
:scriptnames

"surround with surround.vim
"ys works like v without highlight
ys                   : valid vim motion with with surround.vim
ysiwa                : make <^> around "inner word"
ysiwp                : make <p>^</p> around "inner word" with linebreaks
ysiwr   ysiw]        : make [^] around "inner word" with linebreaks
ysiwb   ysiw)        : make (^) around "inner word" with linebreaks
dst                  : remove tags surrounding a string
ysiw<div<CR>         : make <div>^</div> around "inner word"
ysiw<C-t>div<CR>     : make <div>^</div> around "inner word"
                       tags will appear on lines by themselves
ysiW<div<CR>         : make <div>^</div> around "outer word"
ySS<div<CR>          : make <div>^</div> around line with linebreaks
Vjs<div<CR>          : make <div>^</div> around current line and 1 line below it
v_s<div<CR>          : make <div>^</div> around selected lines
v_S<div<CR>          : make <div>^</div> around selected lines with linebreaks
v_b_s<div<CR>        : make <div>^<div> around selected block in each line
v_b_$s<div<CR>       : make <div>^<div> around selected block in each line
i_<C-g>s<div>        : insert <div>|</div>
i_<C-g>S<div>        : insert <div>|</div> with linebreaks

"window
ctrl-w L             : move current window to right with full height
                     : L K J H -> right up down left
vim: set expandtab ts=21 foldmethod=expr foldexpr=getline(v:lnum-1)=~'^\s*$'&&getline(v:lnum)=~'\S'?'>1':1 :

Leave a Reply

You must be logged in to post a comment.