Reply to message «Saving/reusing (sub)patterns», 
sent 15:29:09 15 December 2010, Wednesday
by BPJ:

Vim patterns are normal strings. I do not know any way to save a compiled 
version, but you can use variables to construct a pattern. Here are some pieces 
of code from my YAML syntax file:

=================================== yaml.vim ===================================
let s:ns_word_char = '\%(\w\|-\)'
let s:ns_uri_char  = '\%(%\x\x\|'.s:ns_word_char.'\|[#/;?:@&=+$,.!~*''()\[\]]\)'
let s:c_verbatim_tag = '!<'.s:ns_uri_char.'\+>'
let s:ns_local_tag_prefix  = '!'.s:ns_uri_char.'*'
let s:c_named_tag_handle     = '!'.s:ns_word_char.'\+!'
let s:c_secondary_tag_handle = '!!'
let s:c_primary_tag_handle   = '!'
let s:c_tag_handle = '\%('.s:c_named_tag_handle.
            \         '\|'.s:c_secondary_tag_handle.
            \         '\|'.s:c_primary_tag_handle.'\)'

execute 'syn match yamlTagHandle contained nextgroup=yamlTagPrefix '.
            \      string(s:c_tag_handle.'\s\+')
================================================================================

I think it is clear enough why I have written that.


Original message:
> Is it possible in vimscript to save and reuse a
> (complex) (sub)pattern similar te Perl's qr// ?
> 
> As usual I seem unable to find the right help
> section because of not knowing the right search
> term...
> 
> /bpj

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to