Re: perl x modifier regex ?
A.J.Mechelynck a écrit : You can always add one or more lines of comments above or below the line including the pattern in a Vim script, or even, in most cases, at the end of the line; but IIUC you cannot insert comments in the middle of a pattern. Ok. There is no solution so i decided to write functions that returns RE chunks in vimfiles/autoload/RE{,/XML}.vim 2 advantages to proceed like this : - readable. - reusable For Exemple, the way to match an XML tag is almost a FAQ on this list. Why not provide something like the awsome Regexp::Common perl module ? I wrote : function RE#Magic() return '\v' endfunction function RE#Submatch( regExp ) return '('.a:regExp.')' endfunction function RE#OptionnalSubmatch( regExp ) return '(%('.a:regExp.'){0,1})' endfunction function RE#XML#Ident() return '[[:alpha:]][[:alnum:]]*' endfunction function RE#XML#NSIdent() let ident = RE#XML#Ident() " a namespace " : separator " a tagname return \ RE#OptionnalSubmatch( ident ) . \ RE#OptionnalSubmatch( ':' ) . \ RE#OptionnalSubmatch( ident ) . endfunction Comments and advices about it would be really nice. To use perl regexps, you can of course embed perl statements in a perl-enabled version of Vim; but of course at the cost of making the script less portable. I gave this solution away a long time ago. I think that all alien langages (langages other than viml) is the worst idea of the vim developper team. regards mc
Re: perl x modifier regex ?
Hi Theerasak, my problem is not to read the regExp but maintain them so your script don't help here. It sounds good btw. Regards, mc Theerasak Photha a écrit : On 12/28/06, Marc Chantreux <[EMAIL PROTECTED]> wrote: hi all, Is there a way to obtain the perl x modifier behaviour in vim regex (spaces are non significants, comments are allowed). This is very usefull to make a regexp more readable. No, but there is this: http://www.vim.org/scripts/script.php?script_id=1091
Re: perl x modifier regex ?
Marc Chantreux wrote: hi all, Is there a way to obtain the perl x modifier behaviour in vim regex (spaces are non significants, comments are allowed). This is very usefull to make a regexp more readable. regards mc You can always add one or more lines of comments above or below the line including the pattern in a Vim script, or even, in most cases, at the end of the line; but IIUC you cannot insert comments in the middle of a pattern. To use perl regexps, you can of course embed perl statements in a perl-enabled version of Vim; but of course at the cost of making the script less portable. Best regards, Tony.
Re: perl x modifier regex ?
On 12/28/06, Marc Chantreux <[EMAIL PROTECTED]> wrote: hi all, Is there a way to obtain the perl x modifier behaviour in vim regex (spaces are non significants, comments are allowed). This is very usefull to make a regexp more readable. No, but there is this: http://www.vim.org/scripts/script.php?script_id=1091