Search code examples
vimcopymodeex

How to copy command string in the ex mode into clipboard?


How to copy command string in the ex mode into clipboard?

enter image description here


Solution

  • You can turn the command-line mode into a full Vim buffer named the command-line window by pressing <C-f> after entering in command-line mode with :, or enter into it directly via q:. There, you can yank as usual; e.g. via "+yy or :yank +<CR>. (This is also great for other complex edits!)

    The last command-line is in register :; :let @+ = @:<CR> will copy that to the clipboard.

    The least Vim-like approach would be selecting with the mouse; on Linux, the text is then in the X primary selection; on Windows, you can then use Edit > Copy to put it in the clipboard.