From 815d3fc623c242ce14b70610bdb88844c32b9016 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Thu, 13 Apr 2017 20:00:15 +0200 Subject: [PATCH] Commands: add execute() to :redir section --- README.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5c8c8d9..7a325e3 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ - [:global and :vglobal](#global-and-vglobal) - Execute a command on all matching lines. - [:normal and :execute](#normal-and-execute) - The scripting dream team. -- [:redir](#redir) - Redirect messages. +- [:redir and execute()](#redir-and-execute) - Capture command output. ### [Debugging](#debugging-1) @@ -2143,21 +2143,32 @@ down "n" lines: :execute 'normal!' n . 'j' ``` -## :redir +## :redir and execute() Many commands print messages and `:redir` allows to redirect that output. You can redirect to files, [registers](#registers) or variables. ```vim -:redir => neatvar +:redir => var :reg :redir END -:echo neatvar +:echo var :" For fun let's also put it onto the current buffer. -:put =nicevar +:put =var ``` -Help: `:h :redir` +In Vim 8 there is an even shorter way: + +```vim +:put =execute('reg') +``` + +Help: + +``` +:h :redir +:h execute() +``` # Debugging