After pressing <C-g>
in normal mode, prints useful information in the status line. How can I yank this text?
-
Welcome to Vi and Vim!– filbrandenCommented May 23, 2022 at 20:19
-
If you use tmux you can yank any text printed to the terminal.– ZinklestoffCommented May 24, 2022 at 22:41
Add a comment
|
1 Answer
The output of <C-g>
is the same as that of the :file
command with no arguments.
In order to capture the contents of a command such as :file
, you can use the execute()
Vimscript function.
For example, to paste those contents below the current line, in the current buffer, you can use:
:put =execute('file')
Or to capture those contents in register x
, you can use:
:let @x = execute('file')
Followed by something like "xp
to paste those contents from the register into the buffer.
-
3And of course with clipboard support
:let @* = execute('file')
– D. Ben Knoble ♦Commented May 23, 2022 at 23:33