Tips for vim usage

If cursor jumps word instead of characters in xterm

Change xterm keyboard type to “vt220” with parameter '-kt “v220”'.

Insert prefix to lines

CTRL-V and select the block of lines. Press 'I', type the prefix string and press ESC twice.

Select all

Type: 'ggVG'.

This will jump to the first position in the file ('gg'), toggle visual line ('V') and jump to last position in the file ('G').

Insert symbol from ASCII tabel

While in insert mode ('i'):

'CTRL-V' and type symbol number (out 'x' before number if its hexadecimal).

Find/Replace

%s/<pattern>/<replace with>/<option> (in visual block mode leave the '%' out)

Options:

  • If empty, replace for first instance of pattern in line
  • g — Replace for each instance in line
  • gc — Replace for each instance in line and ask for confirmaion
  • gi — Replace for each instance in a line case insensitive

To do it in a visual block only, select block, press ':' and fill the line as:

  • :'<,'>s/replace_text/with_text/g
 
vimtips.txt · Last modified: 2013/01/08 08:27 by jsc
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki