%s///n
show number of matching pattern like 102 matches on 102 lines.
How to copy this output to a register?
%s///n
show number of matching pattern like 102 matches on 102 lines.
How to copy this output to a register?
:redir @a | %s///n | redir END
An alternative is
:let @a=execute('%s///n')
If %s///n is the last command, you can type:
:let @a=execute('<Ctrl-r>:')
or if you want to paste it immediately into the document, switch to insert mode and type
<Ctrl-r>=execute('<Ctrl-r>:')
Relevant Links
:h :redir:h execute():Redir https://gist.github.com/intuited/362802 :R %s///n @a@: is. Some people develop the habit of pressing :w without thinking about it and 'mess up' the register @:. Pressing <C-r>: tells you immediately what you gonna execute.
– Hotschke
Dec 09 '18 at 10:24