User Tools

Site Tools


Simple vi/vim handling

Line numbers

Show line numbers:

:set nu

“Unshow” line numbers:

: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

Current line = .

Insert comment character on current and next 5 lines:


Change all appearances of from to morf from line 1 to current line:


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

simple_vi_vim_handling.txt · Last modified: 2012/01/12 12:39 by root