I sent the email too soon. I think this question was asked and replied at http://groups.google.com/group/vim_use/browse_thread/thread/ab9c297a30bffcf1/75db1eff8dacffaf?hl=en&lnk=gst&q=use+a+variable+as+search+pattern#75db1eff8dacffaf
On Jan 4, 5:44 pm, Karl Cai <[email protected]> wrote: > 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
