My favourite tips for vim

Useful plug-ins

Some plug-ins I always keep in my .vim/ directory:

  • vimspell: Very useful for writing important e-mails.

Various tips & tricks

  • Switch buffers (with Ctrl-Tab)
map <C-TAB> :bn<CR>
map <C-S-TAB> :bp<CR>
  • Marks
  • regexp replace (:%s/xxx/yyy/c)
  • vimdiff ( [c ]c do dp)
  • search next/previous char (f/F repeat with ;/.)
    • f includes the character (use with 'c' with the last letter to change)
    • t doesn't include the char (use with 'c' with the following letter)
  • use registers
    • “1 is previous yank, etc…
    • “ay yanks in 'a' register
  • indentation
    • == for current line
    • = in visual mode
    • =a{ current {} block
  • visual mode
    • aB select a {} block
    • gv selects previous block
    • v exchange start/end in visual mode
  • command line editing (searching files to edit…)
  • print a control character verbatim (e.g. ^M) by using ^V
  • Tags
    • C-] to jump to def, C-t to come back
    • g] to show a menu before jumping
    • C-W } show the tag under cursor in the preview window, C-W z to close qf
  • Command line editing:
    • C-D show all possible completions
    • C-W delete the last word
  • Macros:
    • q{a-z0-9} to record in said register (uppercase to add)
    • q to stop
    • @{a-z0-9} to execute the register (@@to repeat the previous)
    • to run a macro on every line of the selection: :'<,'>normal @q
    • on every line of the file: :%normal @q
  • Increment/decrement the number under the cursor: C-a/C-x
  • Spelling:
    • Suggest a correction for the word under the cursor: z=
notes/my_favourite_tips_for_vim.txt · Last modified: 2010/02/10 16:01 by nicko