Is it possible in vimscript to save and reuse a (complex)
(sub)pattern similar te Perl's qr// ?

While I don't know what Perl's "qr//" does (I'm more of a Python guy), you can certainly save complex patterns and reuse them:

Save something recently searched:
  /complex_pattern_1
  :let cp1=@/

Save something without searching for it first:

  :let cp2='complex pattern 2'

(be aware of various needs for escaping)

Then you can use control-R followed by equals to insert the saved-names into your search register:

 /search for<C-R>=cp1<CR> and <C-R>=cp2<CR> that I saved

(where "<C-R>" means control+R and "<CR>" means pressing enter to accept the expression).

You can also use the history window:

  q/

to go back and modify/re-execute a previous search.

For more details:

  :help @/
  :help c_CTRL-R_=
  :help q/

Hope this helps get you something like what you want.

-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