How to redirect ex command output into current buffer or file?

前端 未结 6 1864
面向向阳花
面向向阳花 2020-11-30 21:58

How can I redirect or pipe the output of an ex command into my current buffer or a file?

For example, I want to read the contents of all the registers into the curre

6条回答
  •  Happy的楠姐
    2020-11-30 22:37

    :redir @a
    :registers
    :redir END
    "ap
    

    :redir @a redirects all messages from here on to a register named a. You follow this with your command whose output you want to capture (:registers in your case). :redir END ends the redirection. "ap means, "a uses the register named a and p puts the contents of the selected register into the current buffer.

    See Capture ex command output at Vim Tips Wiki for more information :-)

提交回复
热议问题