We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free. Anti-spam check. Do not fill this in!==Capturing output== Redirection can capture the output generated by Vim commands. Redirection to clipboard register <code>+</code> (or use any other register a-z): <pre> :redir @+ :history :g/fred/ " any other commands :redir END </pre> The output from the commands used is now in register <code>+</code> which might pasted into a new buffer, for example by entering <code>:new</code> then typing <code>"+p</code> to paste. If wanted, you can temporarily turn off Vim's paging so there will be no "More" prompts, as shown in the following example which outputs to register <code>A</code> (so output is appended to register <code>a</code>): <pre> :redir @A :set nomore :echo 'History' :history :echo 'Scripts loaded' :scriptnames :set more :redir END </pre> Redirection to a file: <pre> :redir > out.txt :registers " any other commands :redir END </pre> The above writes to the new file <code>out.txt</code>. The command does nothing if that file already exists. To overwrite the file if it exists, use <code>:redir! > out.txt</code>. To create a new file or append to an existing file, use <code>:redir >> out.txt</code>. Store glob results in register <code>a</code>: <pre> " Clear @a (register a) because need to use A to append. :let @a = '' " Append all lines containing 'fred' to register a. :g/fred/y A " Append to a file (must use >>). :'a,'b g/^Error/ .w >> errors.txt </pre> The last command uses the <code>:.w</code> command which writes the current line (<code>.</code>) by appending it to file <code>errors.txt</code>. Summary: Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA Cancel Editing help (opens in new window) Retrieved from "https://vim.fandom.com/wiki/Use_filter_commands_to_process_text"