How do I capture shell command output directly into a Vim register?
:let @a = system('cmd')
You can populate any Vim register with the output of an external shell command using :let @{register} = system('{command}').
225 results for "paste"
:let @a = system('cmd')
You can populate any Vim register with the output of an external shell command using :let @{register} = system('{command}').
:echo getregtype('a')
The getregtype() function returns the motion type of a register's content — whether it was yanked characterwise, linewise, or as a visual block.
"ayy "byy "cyy
How it works Vim provides 26 named registers (a through z) that you can use as independent clipboards.
:set clipboard=unnamedplus
Setting clipboard=unnamedplus makes Vim's default yank and paste use the system clipboard.
"1p
Vim automatically stores your deletion history in numbered registers "1 through "9.
"ayv
Using named registers with visual mode lets you store multiple independent snippets simultaneously.
:let @+=@%
The % register always holds the name of the current file (as a relative path).
:let @a = expand('%:p')
Named registers are not only for yanked text.
registers #registers #command-line #filename-modifiers #editing
"+y
The "+y command yanks (copies) text into the system clipboard register, making it available to paste in other applications outside of Vim.
:let @a = '...'
When a recorded macro contains a typo or needs a small tweak, you can modify it directly via the :let command rather than re-recording the entire sequence.
:let @+ = expand('%:p')
Sometimes you need to share or use the full path of the file you're editing — for a terminal command, a config file, or a chat message.
:redir @a | messages | redir END<CR>
When debugging a session or building repeatable edits, it is useful to turn command output into editable text.
:call setreg('a', @a, 'V')
When you paste from a register, Vim uses that register's stored type: characterwise, linewise, or blockwise.
"+yy
The "+yy command yanks the current line directly to the system clipboard register, making it available for pasting in other applications.
"{register}y{motion}
Vim has 26 named registers (a-z) that act as independent clipboards.
registers #registers #editing #normal-mode #yank #productivity
<C-w>n
n creates a new empty buffer and opens it in a horizontal split above the current window.
"qp
Macros are stored as plain text in named registers.
:@:
The : register stores the last command-line command.
:m {address}
How it works The :m command (short for :move) moves one or more lines to after the specified address.
"*
On X11 Linux systems, there are two independent clipboard-like buffers: the primary selection (") and the clipboard ("+).