Tuesday, July 28, 2009

Insert Register Contents

If you're in insert mode and would like to insert the contents of a given register without going into normal mode, you can hit ctrl-r and then input the desired register. Between typing ctrl-r and the second character, a '"' will be displayed to indicate that you are expected to enter a register.

4 comments:

Unknown said...

Nice tip that :) Vim's registers are another great feature, though I have a habit of forgetting them ... especially this one. So thanks for the reminder.

Douglas said...

I find the most useful registers to be the "special" registers:

" text of the last delete or yank
% current file name
# alternate file name

There are a lot more too - see them in the help:

:help i_ctrl-r

freegnu said...

That Ctrl-R trick works at the ex command prompt. The unamed register comes in handy when you want to add the last yank or delete to the command line.

Travis Whitton said...

Nice tips guys. Thanks for the info!