How to copy text from commandline mode in Vim

那年仲夏 提交于 2020-01-01 05:20:10

问题


I type this command in Vim:

:nmap <CR> <C-]>

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

Thanks


回答1:


The fastest way is to run the command, switch to the destination buffer (with .vimrc loaded, in this case) and paste the whole command from the : register by typing

":p

in Normal mode.

If the command is far back in time, one can first recall it from history (typing the first few letters and pressing Up, for example), rerun and then use the above method.

When these shortcuts are unhandy, one 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 by cedit option (Ctrl+F, by default) in Command-line mode.




回答2:


You can type Ctrl-F while in command mode to open up a special window with all previous commands. Then you can scroll to the desired line, hit yy to copy that 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.



来源:https://stackoverflow.com/questions/7047618/how-to-copy-text-from-commandline-mode-in-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!