Files
dotfiles/vim/wiki/vim.wiki
2014-02-05 14:27:09 +01:00

99 lines
4.4 KiB
Plaintext

%toc
=VIM=
==Remove trailing whitespace==
{{{class="brush: bash; ; toolbar: false;"
:%s/\s\+$//e
}}}
==Remove blank lines==
{{{class="brush: bash; ; toolbar: false;"
:g/^\s*$/d
}}}
==Swap word with next word==
{{{class="brush: bash; ; toolbar: false;"
nmap <silent> gw "_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<cr><c-o><c-l>
}}}
==delete all HTML tags==
{{{class="brush: bash; ; toolbar: false;"
:%s#<[^>]\+>##g
}}}
==delete all duplicate lines==
{{{class="brush: bash; ; toolbar: false;"
:%s/^\(.*\)\n\1$/\1/
}}}
==reverse content of file==
{{{class="brush: bash; ; toolbar: false;"
:g/^/m0
}}}
==useful keymaps==
| *xp* | exchange the right character with his left combatant |
| *^* | move to the first non-blank character in the current line |
| *+* | move to the first character in the next line |
| *-* | move to the first character in the previous line |
| *%* | move to the opposite character |
| *(* | move a sentence back |
| *)* | move a sentence forward |
| *{* | move a paragraph back |
| *}* | move a paragraph forward |
| _n_*yy* | yanks _n_ lines into the buffer |
| */*_string_ | search forward for _string_ |
| *?*_string_ | search backward for string |
| *n* | search for next instance of _string_ |
| *N* | search for previous instance of _string |
| *zf*_3_ | fold the next _3_ lines (works with VISUAL MODE too |
| *zO* | open all folds at the cursor |
| *d/*_string_*/* | delete until _string_ |
| * | find word under cursor |
| *~* | change case |
| *:ls* | list of all buffers |
| *:bn* | next buffer |
| *:bp* | previous buffer |
| *:bd* | remove file from buffer |
| *:b2* | go to buffer _3_ |
| *<C-v>* | enter VISUAL BLOCK mode |
| *Vip* | select code block |
| *g<C-g>* | count all words in document |
| *s*_<p>_ | surrounding the line with _<p>_ _</p>_ tags (_surround_ plugin in visual mode) |
| *=G* | apply autoformat to the end of a file in visual mode |
==replace pattern==
| *:s/*_pattern_*/*_string_*/*_flags_ | replace _pattern_ with _string_ according to _flags_ |
| *g* | Flag - replace all occurences of _pattern_ |
| *c* | Flag - confirm replaces |
| *.* | any single caracter except newline |
| * | zwro or more occurances of any character |
| *^* | beggining of the line |
| *$* | end of line |
| *\<* | beginning of word |
| *\>* | end of word |
[ [[index|Go home]] ]