1

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?

Fisher
  • 1,086
  • 2
  • 13
  • 28

2 Answers2

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
  • You can also use 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
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