0

At the bottom of my file, I'd to have something like this:

// vim: syntax=cpp.doxygen

Only, when I do that, it breaks my auto-load of my own cpp.vim.

au BufNewFile,BufReadPost *.cpp          so $HOME/vim/presentrack.vim

I write code where my with C++ classes have variable members that start with f_ and with my syntax I see those in a specific color.

Also I define some global variables (rarely, though) which start with g_. Again I give them a special color.

I also like the special doxygen highlighting because it shows me whether I mistype something without having to run doxygen (it helps fixing some mistakes quickly.)

Is there a way to get the best of both worlds?

Right now, my presentrack.vim has an include:

source $VIMRUNTIME/syntax/cpp.vim

and I would imagine I would have to instead include doxygen and not have doxygen at the bottom of my .cpp file?

What I'd like is a way that both syntaxes would co-exist, although I would imagine that is not supported, I thought I'd ask.

2

when I do that, it breaks my auto-load of my own cpp.vim.

au BufNewFile,BufReadPost *.cpp          so $HOME/vim/presentrack.vim

The canonical way to extend the syntax highlighting for the cpp filetype would be to put your custom rules in ~/.vim/after/syntax/cpp.vim. That will automatically be loaded for you.

  • Or if OP really likes the name presentrack (could be inhouse company style related), could use ~/.vim/after/syntax/cpp/presentrack.vim (i think) – D. Ben Knoble Mar 7 '18 at 15:49
  • I was going to suggest something like that, but the {filetype}_foo.vim and {filetype}/foo.vim naming only works for ftplugin/. – jamessan Mar 7 '18 at 15:55
  • Darn. Thats actually kind of disappointing. – D. Ben Knoble Mar 7 '18 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.