How to copy text from command line mode in Vim

I type this command in Vim:

:nmap <CR> <C-]> 

Then I want to copy this line and put it in my .vimrc How can I select and copy the whole line in command line mode?

thanks

+7
source share
2 answers

The fastest way is to run the command, switch to the destination buffer (in this case, load .vimrc ) and insert the entire command from register : by typing

 ":p 

in normal mode.

If the team returned on time, you can first recall it from the story (for example, by typing the first few letters and pressing Up ), try again, and then use the above method.

When these shortcuts are unmanageable, you can resort to a general approach using the command line window (see :help cmdwin ). To open it, either type q: in normal mode or press the key combination specified in cedit ( Ctrl + F , by default) in Command Line Mode.

+8
source

You can enter Ctrl - F in command mode to open a special window with all previous commands. Then you can scroll to the desired line, press y y to copy this line, then press Ctrl - C to return to command mode, and then ESC to return to normal mode. From there you can paste.

See :help cmdwin for more information on the command window.

+9
source

All Articles