Last Updated: December 26, 2018
·
882
· cwood

Copy yanked text to vim command line

A lot of times you have something you want to yank such as a file path or something you want to run over a regex. Lets say you grab a file path from a piece of code you are editing. And you want to do something like the following.

:edit /a/path/to/a.file

But a.file is your register "
So what you can do is

:edit <CTRL-R>"

Which becomes

:edit /a/path/to/a.file

And this will add your yanked code into the vim command line.

See the following for more information.

:help c_CTRL-R

1 Response
Add your response

This works in insert mode too! Also useful in insert mode: inserting from the "=" register, which lets you insert the result of vim commands.

over 1 year ago ·