> Can somebody tell me how to use an expression (e.g., the
> output of a command) as the search pattern? I am using vim
> 7.0.94
>
> For example:
> :let x = system("hostname") # say x is "mycomputer" now. This
> : should work %s/$x/yourcomputer/g # trying to change
> : all "mycomputer" to
>
> "yourcomputer". This doesn't work
> Or
>
> :%s/\=x/yourcomputer/g # same purpose, but doesn't work
> : either.
>
i think you're looking for the execute command -- something along
the lines of
exe "%s/" . x . "/yourcomputer/g"
should work -- see
:help execute
for a more detailed explanation
sc
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment