# HG changeset patch # User Steve Losh # Date 1350086267 14400 # Node ID 2ca28cad56b93c3c64be8e4910175eb68c777f88 # Parent 49efcbc3a5223977920b7714cb6420986dd2c0d3 Fix syntax priority. Thanks to @tapichu on GitHub for pointing this out. diff -r 49efcbc3a522 -r 2ca28cad56b9 chapters/46.markdown --- a/chapters/46.markdown Fri Oct 12 19:53:00 2012 -0400 +++ b/chapters/46.markdown Fri Oct 12 19:57:47 2012 -0400 @@ -66,15 +66,15 @@ following to your syntax file: :::vim - syntax match potionOperator "\v\*\=" - syntax match potionOperator "\v/\=" - syntax match potionOperator "\v\+\=" - syntax match potionOperator "\v-\=" syntax match potionOperator "\v\*" syntax match potionOperator "\v/" syntax match potionOperator "\v\+" syntax match potionOperator "\v-" syntax match potionOperator "\v\?" + syntax match potionOperator "\v\*\=" + syntax match potionOperator "\v/\=" + syntax match potionOperator "\v\+\=" + syntax match potionOperator "\v-\=" highlight link potionOperator Operator @@ -102,8 +102,8 @@ I also never defined `=` as an operator. We'll do that in a second, but I wanted to avoid it for now so I could teach you a lesson. -Because I used separate regexes for `-` and `-=` I had to define `-` *after* -`-=`! +Because I used separate regexes for `-` and `-=` I had to define `-=` *after* +`-`! If I did it in the opposite order and used `-=` in a Potion file, Vim would match `-` (and highlight it, of course) and only `=` would remain for matching. @@ -112,7 +112,8 @@ This is an oversimplification, but I don't want to get bogged down in the details just yet. For now, your rule of thumb should be to match larger groups -first and smaller groups later. +after smaller groups later because groups defined *later* have priority over +groups defined *earlier*. Let's go ahead and add `=` as an operator, now that we've had our lesson: @@ -127,6 +128,8 @@ Read `:help syn-match`. +Read `:help syn-priority`. + We didn't make `:` an operator in our example. Read the Potion docs and make a conscious decision about whether to make `:` an operator. If you decide to do so, add it to the syntax file.