How do I copy the output from an ex-command into a buffer?

To copy the output from an ex-command into a buffer, you have to first get the command output into a register. You can use the “:redir” command to get the output into a register. For example,

    :redir @a

    :g/HelloWord/p

    :redir END

Now the register ‘a’ will contain the output from the ex command “g/HelloWord/p”. Now you can paste the contents of the register ‘a’ into a buffer. You can also send or append the output of an ex-command into a file using the ‘redir’ command. You can prefix the “:global” command with “:silent”, to avoid having the lines printed to the screen. To redirect the output from an ex-command to a file, you can use the following set of commands:

    :redir > myfile

    :g/HelloWord/p

    :redir END

Comments (1)


Pepsh Pepshinsky

Let’s see you to :help viminfo-file-name (option -i) :set viminfofile=NONE


Speak Your Mind