31 October, 2009

Vim command line editing

Paste the contents of register into the command line is very useful, for example, you can edit a non-trivial command in normal vim buffer, or you can copy some text from the file. There are at least two way to do it:

The 'CTRL_R', in command mode, can be used for this [:help c_CTRL-R]

  1. Assume you saved some text in register 'a'
  2. Under command mode, press 'Ctrl-R a'
  3. The text in register 'a' will pasted in the command line

One powerful alternative is the command window [:help q:]

  1. Under normal mode, use 'q:' to enter command window
  2. Editing the command
  3. Press 'Enter' to execute, or 'Ctrl-C' to quit this mode

This two method is provided by Tim on the thread

No comments: