|
experts:
how to comment a long regex? it looks normal line continuation doesn't work here -- I have to put everything in one line, which becomes painful as it goes long... syn region erxLog \start=/^\(\S\S\+.\{0,45}\S[#>%]\s*\S\+\|slot \d\d\=->\S\+\|->.\+\|\*-\*-\*-\*-\*-\)/ \end=/^\(\S\+.\{0,45}\S[#>%]\|^[#>%]$\|->\|slot \d\d\=->\|\*-\*-\*-\*-\*-\)/me=s-1 fold regards ping -- 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 |
|
On Sunday, August 5, 2012 10:02:13 PM UTC-5, ping wrote:
> experts: > > how to comment a long regex? > > it looks normal line continuation doesn't work here -- I have to put > > everything in one line, which becomes painful as it goes long... > > > > syn region erxLog > > \start=/^\(\S\S\+.\{0,45}\S[#>%]\s*\S\+\|slot > > \d\d\=->\S\+\|->.\+\|\*-\*-\*-\*-\*-\)/ > > \end=/^\(\S\+.\{0,45}\S[#>%]\|^[#>%]$\|->\|slot > > \d\d\=->\|\*-\*-\*-\*-\*-\)/me=s-1 fold > The only way I know of is to build a string and then use :exe on the string rather than giving the command directly, e.g. let pattern='apples' " apples are healthy let pattern.='\|bananas' " and bananas are delicious exec 'syn match ILikeToEat /'.pattern.'/' -- 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 |
|
On Aug 6, 8:48 am, Ben Fritz <[hidden email]> wrote:
> let pattern='apples' " apples are healthy > let pattern.='\|bananas' " and bananas are delicious These do the same thing: let @/ = @/ . pad[c] let @/ .= pad[c] Is there an advantage (speed, space) to use one rather the other? Bill -- 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 |
|
In reply to this post by Ben Fritz
thanks Ben.
I miss perl on the ability to comment liekt his: ... $dataline=~(/ \s* (\w+) #wanted value \s* = #= \s*{\s* (.*?) #cli \s*}\s* (?: (?: #either followed by ptn(s) : #: \s*{\s* (.*?) #ptn1 \s*} (?: #ptn2 or nothing : \s*\{\s* (.*?) #ptn2 \s*\}\s* | #or... \s* #nothing ) ) | #or \s* #no ptns at all ) /x) On 08/06/2012 11:48 AM, Ben Fritz wrote: > On Sunday, August 5, 2012 10:02:13 PM UTC-5, ping wrote: >> experts: >> >> how to comment a long regex? >> >> it looks normal line continuation doesn't work here -- I have to put >> >> everything in one line, which becomes painful as it goes long... >> >> >> >> syn region erxLog >> >> \start=/^\(\S\S\+.\{0,45}\S[#>%]\s*\S\+\|slot >> >> \d\d\=->\S\+\|->.\+\|\*-\*-\*-\*-\*-\)/ >> >> \end=/^\(\S\+.\{0,45}\S[#>%]\|^[#>%]$\|->\|slot >> >> \d\d\=->\|\*-\*-\*-\*-\*-\)/me=s-1 fold >> > > The only way I know of is to build a string and then use :exe on the string rather than giving the command directly, e.g. > > let pattern='apples' " apples are healthy > let pattern.='\|bananas' " and bananas are delicious > exec 'syn match ILikeToEat /'.pattern.'/' > -- 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 |
|
In reply to this post by Bee-16
On Monday, August 6, 2012 1:08:44 PM UTC-5, Bee wrote:
> On Aug 6, 8:48 am, Ben Fritz <[hidden email]> wrote: > > > let pattern='apples' " apples are healthy > > > let pattern.='\|bananas' " and bananas are delicious > > > > These do the same thing: > > let @/ = @/ . pad[c] > > let @/ .= pad[c] > > > > Is there an advantage (speed, space) to use one rather the other? > > > > Bill I don't know the internals of Vim's implementation. It might be slightly faster to use "let var .= val" rather than "let var = var . val" because Vim might use extra resources to evaluate var before concatenating val in the latter, but conceptually they do the same thing and I have no reason no suspect there is a performance difference one way or the other. I just like using .= because it's less typing and makes for much shorter lines; especially when you use long variable names, or fields of a dictionary object or array items rather than regular variables. -- 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 |
|
In reply to this post by ping
On Monday, August 6, 2012 2:49:40 PM UTC-5, ping wrote:
> thanks Ben. > > > > I miss perl on the ability to comment liekt his: > > > > ... > > > > $dataline=~(/ > > \s* > > (\w+) #wanted value > > \s* > > = #= > > \s*{\s* > > (.*?) #cli > > \s*}\s* > > (?: > > (?: #either followed by ptn(s) > > : #: > > \s*{\s* > > (.*?) #ptn1 > > \s*} > > (?: #ptn2 or nothing > > : > > \s*\{\s* > > (.*?) #ptn2 > > \s*\}\s* > > | #or... > > \s* #nothing > > ) > > ) > > | #or > > \s* #no ptns at all > > ) > > /x) > I figured that's what you meant. You can't do that in Vim script in the same way, but you can run perl (or python, scheme, LUA, etc.) directly from Vim script, so depending on what you're doing it might be possible to drop into Perl for a regex or something. -- 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 |
| Powered by Nabble | Edit this page |
