A place for opinions and notes of a valibuk.

Useful Vim Tips

Tagged with: — ondrej at 10:00 am on Friday, June 27, 2008

Vim is my favourite editor. I search for tips from time to time – and there are still nice surprises. After a few years of using it, it is high time to write down my own list of useful tips :)

Here is it:

  • delete rest of line – to delete the rest of the current line press Shift-D (in the command mode).
  • repeat last command – to repeat the last command, press . (dot) (of course, in the command mode).
  • completion – saves typing and time esp. for longer words. Press Ctrl-N (in the edit mode) to get a word or a list of words that have the same prefix as the word on the cursor position.
  • path completion – great for bash scripts, images or CSS in HTML or Ant scripts. Ctrl-X-F (press and hold Ctrl, press X, release it and press F) (in the edit mode) shows a list of directories and files in the actual directory or will complete a directory or file name if the already typed prefix is unique. Of course, it works with absolute and relative paths too.
  • bookmark – to store/mark the actual position press M (lower case m) and then any letter key(in the command mode) as the mark of this bookmark, e.g. M A for bookmark a or M Q for bookmark q. To go to the bookmarked position, press ` and the stored mark, e.g. ` A will move you to the bookmark a.
    If you need more a lot of bookmarks, you may use lower and upper case marks, i.e. M A and ` A for mark a, but M Shift-A and ` Shift-A for mark A.
  • comment out multiple lines – press Ctrl-V (the visual block) in the command mode and select more lines, then press Shift-I to start the edit mode, insert one or more characters, e.g. press # to comment out more lines in Ruby, and then press Esc (on some systems twice). (Motivated by Mark’s blog.)
    To uncomment lines, press Ctrl-V, select the block and press d to delete it.
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Digg
  • Reddit
  • Technorati
  • Furl
  • NewsVine
  • Slashdot
  • Ma.gnolia
  • StumbleUpon

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Comment Preview

commercial break :)

Make an account on -- a really good hosting where you have your own virtual machine. I installed Gentoo there = I like it very much ;)