Commands: add execute() to :redir section

This commit is contained in:
Marco Hinz 2017-04-13 20:00:15 +02:00
parent cba3169327
commit 815d3fc623
No known key found for this signature in database
GPG Key ID: 1C980A1B657B4A4F

View File

@ -89,7 +89,7 @@
- [:global and :vglobal](#global-and-vglobal) - Execute a command on all matching lines. - [:global and :vglobal](#global-and-vglobal) - Execute a command on all matching lines.
- [:normal and :execute](#normal-and-execute) - The scripting dream team. - [: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) ### [Debugging](#debugging-1)
@ -2143,21 +2143,32 @@ down "n" lines:
:execute 'normal!' n . 'j' :execute 'normal!' n . 'j'
``` ```
## :redir ## :redir and execute()
Many commands print messages and `:redir` allows to redirect that output. You Many commands print messages and `:redir` allows to redirect that output. You
can redirect to files, [registers](#registers) or variables. can redirect to files, [registers](#registers) or variables.
```vim ```vim
:redir => neatvar :redir => var
:reg :reg
:redir END :redir END
:echo neatvar :echo var
:" For fun let's also put it onto the current buffer. :" 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 # Debugging