David Liang wrote:
I'd like to do something like this, that runs a shell command based on
the matched part, and captures the output to use as replacement text:

:%s/\(fooba.\)/\=read !command \1/gc

How do I phrase the expression in the replacement part ("read !command
\1")? Maybe a functional wrapper or something.

You might be able to do several things:

  :%s/\(fooba.\)/\=system('command '.submatch(1))/gc

or possibly (depending on your pattern)

  :%s/fooba./command &
  :g//!sh

(or whatever your command processor is...cmd.exe, bash, zsh, etc)

If the entire file is of that form (you want to pass each line as parameters to "command", you can reduce the 2nd version to

  :%s/^/command /
  :%!sh

-tim



--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to