Hi Vim-users,
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.
In section 9 (9. Compare with Perl patterns) of doc patten.txt it says:
Finally, these constructs are unique to Perl:
- execution of arbitrary code in the regex: (?{perl code})
Does this mean that vim can't use an arbitrary expression as the search pattern? If so, any known workaround?
Thanks.
-- Karl
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
Monday, January 4, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment