This shows you the differences between two versions of the page.
simple_vi_vim_handling [2011/10/15 08:09] root created |
simple_vi_vim_handling [2012/01/12 12:39] (current) root |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Simple vi/vim handling ====== | ====== Simple vi/vim handling ====== | ||
- | |||
- | Add show/unshow line numbering in vim (F12 key) | ||
- | Add following to /etc/vimrc | ||
- | | ||
- | nmap <F12> :set number!<CR> | ||
===== Line numbers ===== | ===== Line numbers ===== | ||
Line 14: | Line 9: | ||
"Unshow" line numbers: | "Unshow" line numbers: | ||
:set nonu | :set nonu | ||
+ | |||
+ | ===== Vim show line numbers with F12 shortcut ===== | ||
+ | |||
+ | Add show/unshow line numbering in vim (F12 key) | ||
+ | Add following to /etc/vimrc | ||
+ | | ||
+ | nmap <F12> :set number!<CR> | ||
+ | |||
===== Search and replace ===== | ===== Search and replace ===== | ||
Line 24: | Line 27: | ||
Change all appearances of from to morf from line 1 to current line: | Change all appearances of from to morf from line 1 to current line: | ||
:1,.s/from/morf/g | :1,.s/from/morf/g | ||
+ | |||
+ | ===== VIM - Comment blocks of code (visual mode) ===== | ||
+ | |||
+ | Mark the area which is to be commented using the *blockwise* visual mode (CTRL-V)\\ | ||
+ | Press I (capital i) and write the text you want to prepend to each line of the selected block, e.g. %.\\ | ||
+ | Then press ESC and the text will be inserted to the left of each line of the selected block. | ||
+ | |||
+ | ===== VIM - Select line(s) (visual mode) ===== | ||
+ | |||
+ | Shift + v | ||
+ | |||