I have defined a custom file type with these lines:
syn region SubSubtitle start=+=+ end=+=+
highlight SubSubtitle ctermbg=black ctermfg=DarkGrey
syn region Subtitle start=+==+ end=+==+
highlight Subtitle ctermbg=black ctermfg=DarkMagenta
syn region Title start=+===+ end=+===+
highlight Title ctermbg=black ctermfg=yellow
syn region MasterTitle start=+====+ end=+====+
highlight MasterTitle cterm=bold term=bold ctermbg=black ctermfg=LightBlue
I enclose all of my headings in this kind of document like this:
==== Biggest Heading ==== // this will be bold and light blue
===Sub heading === // this will be yellow
bla bla bla // this will be normally formatted
However right now when ever I use an equals sign in my code it thinks that it is a title. Is there anyway that I can force a match to be only on one line?
UPDATE: My previous answer was wrong, you can do this with a region, just do
See
:help syn-onelineand:help syn-arguments. Guess it shows that I can’t actually run vim right now, hunh?Previous answer
According to my reading of the :help syntax,
there’s no way to do this with a region. However, you could do this with a syn-match:The
/=\@<!/says there’s no=immediately before your match, and the/=\@!/says there’s no=immediately after, so this matches exactly one=, a bunch of non-=(not including newlines – to include newlines it would have to be\_[^=]), then exactly one=.The rest are similar
You can still do matches within syn-matches, so if you have any nesting going on, it will still work.
For example