For example, I've used redir command to redirect command output to register a.
Register a contains several lines of text.
How to remove a line from register a or substitute a string from it?
Asked
Active
Viewed 91 times
2 Answers
2
The register a is stored in variable @a. If you need a little bit more control you can access the register through the functions setreg() and getreg().
Substitution can be accomplished though the function substitute(), filtering can be done with filter() (but you may need to convert the string into a list first with split(str, "\n"))...
Luc Hermitte
- 17,351
- 1
- 33
- 49
1
You can also make edits interactively by:
- pasting the register contents into your buffer:
"ap - editing with whatever Vim commands you like
- and then yanking or deleting back into the register with e.g.
"adip
Rich
- 31,891
- 3
- 72
- 139
execute()as an alternative to:redir, e.g.let foo = execute('ls'). See:h execute().execute()requires Vim 7.4.2008+ – Peter Rincker Sep 04 '18 at 14:13