Re: syntax match question
Charles E Campbell Jr wrote: Robert Hicks wrote: Charles E Campbell Jr wrote: Is it possible to create a keyword group and then do a match with those words and if they are prefixed with a "-" to color them a certain way? A couple of the actual ones would be: -command -menu -fill -pady -padx -tearoff -label -text -height -width -justify and the list goes on. And you can see why I was hoping a simple match would do it. :-) You can get the effect I think you want with: syn match OptionMatcher "\%(^\|\s\)\zs-\w\+" contains=SpecificOptionList,OptionStarter syn keyword SpecificOptionList contained command menu fill pady padx tearoff label text height width justify syn match OptionStarter contained "-" hi link OptionMatcher Error hi link SpecificOptionList Statement hi link OptionStarter SpecificOptionList These commands will highlight your options; ones that aren't in the keyword list (ex. -junk) would get highlighted as Error. Well that kind of worked. Every word that start with "-" is highlighted as an "Error", including those in the "SpecificOptionList". To test that, I set up two files tmp (with some options contained) and tmp.vim (with the syntax). I then used :so tmp.vim while editing tmp. Anyway, the highlighting worked. I suggest first trying it separately as I did; hopefully you'll see its working. Were you immediately putting that snippet (with adjusted group names) into a local copy of syntax/tcl.vim? Then you'll have to start worrying about priority and interference from and with other syntax highlighting. Yes I am using syntax/tcl.vim as I am trying to improve upon it. Currently there are some options that highlight only a few of the "-" commands so when you open a tcl file with more than those it looks like it is not highlighting them all and so it comes off as looking funny. I was trying to get it to highlight all the "-" options because it will get rid of the other options and be a cleaner solution to the problem. :Robert
Re: syntax match question
Robert Hicks wrote: Charles E Campbell Jr wrote: Is it possible to create a keyword group and then do a match with those words and if they are prefixed with a "-" to color them a certain way? A couple of the actual ones would be: -command -menu -fill -pady -padx -tearoff -label -text -height -width -justify and the list goes on. And you can see why I was hoping a simple match would do it. :-) You can get the effect I think you want with: syn match OptionMatcher "\%(^\|\s\)\zs-\w\+" contains=SpecificOptionList,OptionStarter syn keyword SpecificOptionList contained command menu fill pady padx tearoff label text height width justify syn match OptionStarter contained "-" hi link OptionMatcher Error hi link SpecificOptionList Statement hi link OptionStarter SpecificOptionList These commands will highlight your options; ones that aren't in the keyword list (ex. -junk) would get highlighted as Error. Well that kind of worked. Every word that start with "-" is highlighted as an "Error", including those in the "SpecificOptionList". To test that, I set up two files tmp (with some options contained) and tmp.vim (with the syntax). I then used :so tmp.vim while editing tmp. Anyway, the highlighting worked. I suggest first trying it separately as I did; hopefully you'll see its working. Were you immediately putting that snippet (with adjusted group names) into a local copy of syntax/tcl.vim? Then you'll have to start worrying about priority and interference from and with other syntax highlighting. Regards, Chip Campbell
Re: syntax match question
If I do this: syn match OptionMatcher "\%(^\|\s\)\zs-\w\+" contains=OptionStarter syn match OptionStarter contained "-" hi link OptionMatcher Special That colorizes all the words that start with "-". So in a round about way, it works! :-) :Robert
Re: syntax match question
Charles E Campbell Jr wrote: Is it possible to create a keyword group and then do a match with those words and if they are prefixed with a "-" to color them a certain way? A couple of the actual ones would be: -command -menu -fill -pady -padx -tearoff -label -text -height -width -justify and the list goes on. And you can see why I was hoping a simple match would do it. :-) You can get the effect I think you want with: syn match OptionMatcher "\%(^\|\s\)\zs-\w\+" contains=SpecificOptionList,OptionStarter syn keyword SpecificOptionList contained command menu fill pady padx tearoff label text height width justify syn match OptionStarter contained "-" hi link OptionMatcher Error hi link SpecificOptionList Statement hi link OptionStarter SpecificOptionList These commands will highlight your options; ones that aren't in the keyword list (ex. -junk) would get highlighted as Error. Well that kind of worked. Every word that start with "-" is highlighted as an "Error", including those in the "SpecificOptionList". :Robert
Re: syntax match question
Robert Hicks wrote: According to the isk help file "-" is a keyword character. I am trying to update the Tcl syntax file a bit. Tk has lots of options that start with the "-" character. I was hoping that the above would make it easy to highlight all of the options without a lot of fuss. Is it possible to create a keyword group and then do a match with those words and if they are prefixed with a "-" to color them a certain way? A couple of the actual ones would be: -command -menu -fill -pady -padx -tearoff -label -text -height -width -justify and the list goes on. And you can see why I was hoping a simple match would do it. :-) You can get the effect I think you want with: syn match OptionMatcher "\%(^\|\s\)\zs-\w\+" contains=SpecificOptionList,OptionStarter syn keyword SpecificOptionList contained command menu fill pady padx tearoff label text height width justify syn match OptionStarter contained "-" hi link OptionMatcher Error hi link SpecificOptionList Statement hi link OptionStarter SpecificOptionList These commands will highlight your options; ones that aren't in the keyword list (ex. -junk) would get highlighted as Error. Regards, Chip Campbell
Re: syntax match question
Peter Hodge wrote: Hi, So you want something like: " highlight all var options using this match syntax match allVarOptions "\%(\s\|^\)\zs-\w\+" " highlight the keywords within allVarOptions: " note: because '-' is an iskeyword character, you have to " use a match instead. syntax match allVarOptionKeywords contained containedin=allVarOptions \ "\v%(command|fill|pady|padx|)" Hope that helps, regards, Peter Nada on that working as well. Ah well. :Robert
Re: syntax match question
Hi, So you want something like: " highlight all var options using this match syntax match allVarOptions "\%(\s\|^\)\zs-\w\+" " highlight the keywords within allVarOptions: " note: because '-' is an iskeyword character, you have to " use a match instead. syntax match allVarOptionKeywords contained containedin=allVarOptions \ "\v%(command|fill|pady|padx|)" Hope that helps, regards, Peter --- Robert Hicks <[EMAIL PROTECTED]> wrote: > Charles E Campbell Jr wrote: > > Robert Hicks wrote: > > > >> A word can be anything really, so it would be from "-" to the end. > >> > >> So something like: > >> > >> syn match MyVarOption "\<-\w\+\>" > > > > Unless - is part of normal keyword characters (see :he 'iskeyword'), the > > \<- isn't going to help. > > Probably you want > > > > syn match MyVarOption "\%(\s\|^\)\zs-\w\+\>" > > According to the isk help file "-" is a keyword character. I am trying > to update the Tcl syntax file a bit. Tk has lots of options that start > with the "-" character. I was hoping that the above would make it easy > to highlight all of the options without a lot of fuss. > > Is it possible to create a keyword group and then do a match with those > words and if they are prefixed with a "-" to color them a certain way? A > couple of the actual ones would be: > > -command > -menu > -fill > -pady > -padx > -tearoff > -label > -text > -height > -width > -justify > > and the list goes on. And you can see why I was hoping a simple match > would do it. :-) > > :Robert > > Send instant messages to your online friends http://au.messenger.yahoo.com
Re: syntax match question
Charles E Campbell Jr wrote: Robert Hicks wrote: A word can be anything really, so it would be from "-" to the end. So something like: syn match MyVarOption "\<-\w\+\>" Unless - is part of normal keyword characters (see :he 'iskeyword'), the \<- isn't going to help. Probably you want syn match MyVarOption "\%(\s\|^\)\zs-\w\+\>" According to the isk help file "-" is a keyword character. I am trying to update the Tcl syntax file a bit. Tk has lots of options that start with the "-" character. I was hoping that the above would make it easy to highlight all of the options without a lot of fuss. Is it possible to create a keyword group and then do a match with those words and if they are prefixed with a "-" to color them a certain way? A couple of the actual ones would be: -command -menu -fill -pady -padx -tearoff -label -text -height -width -justify and the list goes on. And you can see why I was hoping a simple match would do it. :-) :Robert
Re: syntax match question
Charles E Campbell Jr wrote: Robert Hicks wrote: A word can be anything really, so it would be from "-" to the end. So something like: syn match MyVarOption "\<-\w\+\>" Unless - is part of normal keyword characters (see :he 'iskeyword'), the \<- isn't going to help. Probably you want syn match MyVarOption "\%(\s\|^\)\zs-\w\+\>" Regards, Chip Campbell I will try tomorrow and let you know... :-) :Robert
Re: syntax match question
Robert Hicks wrote: A word can be anything really, so it would be from "-" to the end. So something like: syn match MyVarOption "\<-\w\+\>" Unless - is part of normal keyword characters (see :he 'iskeyword'), the \<- isn't going to help. Probably you want syn match MyVarOption "\%(\s\|^\)\zs-\w\+\>" Regards, Chip Campbell
Re: syntax match question
Robert Hicks wrote: Tim Chase wrote: I would like to match all "options" that start with a hyphen like: -one -two So all those would be a match from the "-" to the end of the word. Looks like a simple /\<-\w\+\>/ It makes some presumptions where your description falls silent. What constitutes a "word" for you? The vim defintion of a word is embodied by the "\w" atom. However, it includes numbers and an underscore. If that's no good, you can change the "\w" to the set of desired characters with a character-class /\<-[a-zA-Z]\+\>/ Adjust accordingly. -tim A word can be anything really, so it would be from "-" to the end. So something like: syn match MyVarOption "\<-\w\+\>" :Robert I should say this is for a syntax file...so it needs to work from that. :Robert
Re: syntax match question
Tim Chase wrote: I would like to match all "options" that start with a hyphen like: -one -two So all those would be a match from the "-" to the end of the word. Looks like a simple /\<-\w\+\>/ It makes some presumptions where your description falls silent. What constitutes a "word" for you? The vim defintion of a word is embodied by the "\w" atom. However, it includes numbers and an underscore. If that's no good, you can change the "\w" to the set of desired characters with a character-class /\<-[a-zA-Z]\+\>/ Adjust accordingly. -tim A word can be anything really, so it would be from "-" to the end. So something like: syn match MyVarOption "\<-\w\+\>" :Robert
Re: syntax match question
I would like to match all "options" that start with a hyphen like: -one -two So all those would be a match from the "-" to the end of the word. Looks like a simple /\<-\w\+\>/ It makes some presumptions where your description falls silent. What constitutes a "word" for you? The vim defintion of a word is embodied by the "\w" atom. However, it includes numbers and an underscore. If that's no good, you can change the "\w" to the set of desired characters with a character-class /\<-[a-zA-Z]\+\>/ Adjust accordingly. -tim