Re: Matchit's match_words Question
On Tue, Sep 12, 2006 at 07:30:55PM -0500, Bill McCarthy wrote: Thanks, Tony. I was just getting ready to respond to myself with another solution I found with a hint from the help file: let b:match_words = \'\%(\S\+\)\@!text\s*$:\%(\S\+\)\@!endtext\s*$' Hint from :help matchit-spaces Also :help /\@! But I'm still wondering why '\zs' didn't work. Even I do not know for sure. I think the point is that matchit takes 'pat1:pat2' and builds up the regex /\%(pat1\)\|\%(pat2\)/ . If you are just searching for /pat1/ then it does not matter if pat1 is \s*\zstext or \(\s*\)\@=text , but when you build the larger regex, it does make a difference. IIRC, early versions of the script were written before \@= was added so I included a special marker ( I think, inspired by :menu syntax) for when you wanted to position the cursor somewhere other than at the start of the match. HTH --Benji Fisher
Matchit's match_words Question
Hello Vim List, I want to match a line containing only the word text and a line containing only the word endtext. let b:match_words = '^\s*text\s*$:^\s*endtext\s*$' works, but '%' brings me to the beginning of the line, as would be expected from those regexes. Using '\zs' in front of text and endtext causes the '%' mechanism to fail. (I noticed that when I only added the '\zs' in front of the first 'text', the '%' failed while on the 'text' line, but worked from the 'endtext' line - even landing in the correct position.) How do I get matchit to move between the first 't' in 'text' and the first 'e' in 'endtext'? -- Best regards, Bill
Re: Matchit's match_words Question
Bill McCarthy wrote: Hello Vim List, I want to match a line containing only the word text and a line containing only the word endtext. let b:match_words = '^\s*text\s*$:^\s*endtext\s*$' works, but '%' brings me to the beginning of the line, as would be expected from those regexes. Using '\zs' in front of text and endtext causes the '%' mechanism to fail. (I noticed that when I only added the '\zs' in front of the first 'text', the '%' failed while on the 'text' line, but worked from the 'endtext' line - even landing in the correct position.) How do I get matchit to move between the first 't' in 'text' and the first 'e' in 'endtext'? I got it to work with :let b:match_words = '\%(^\s*\)\@=text\s*$:\%(^\s*\)\@=endtext\s*$' see :help /\@= Best regards, Tony
Re: Matchit's match_words Question
On Tue 12-Sep-06 7:10pm -0600, you wrote: Bill McCarthy wrote: I want to match a line containing only the word text and a line containing only the word endtext. let b:match_words = '^\s*text\s*$:^\s*endtext\s*$' works, but '%' brings me to the beginning of the line, as would be expected from those regexes. Using '\zs' in front of text and endtext causes the '%' mechanism to fail. (I noticed that when I only added the '\zs' in front of the first 'text', the '%' failed while on the 'text' line, but worked from the 'endtext' line - even landing in the correct position.) How do I get matchit to move between the first 't' in 'text' and the first 'e' in 'endtext'? I got it to work with :let b:match_words = '\%(^\s*\)\@=text\s*$:\%(^\s*\)\@=endtext\s*$' see :help /\@= Thanks, Tony. I was just getting ready to respond to myself with another solution I found with a hint from the help file: let b:match_words = \'\%(\S\+\)\@!text\s*$:\%(\S\+\)\@!endtext\s*$' Hint from :help matchit-spaces Also :help /\@! But I'm still wondering why '\zs' didn't work. -- Best regards, Bill