Word – Custom Vim Highlighting (only works with specific file types)

bashkeywordsyntax highlightingunixvim

I have this in my vimrc:

"on will override defaults set.  Enable will allow you to set defaults."
syntax enable

...

"attempting to highlight specific keywords so it is easy to see in code."
"see help e410 for more info."
syn keyword JakeKeywords        Question TODO Answer JAKEHTTPS
highlight JakeKeywords cterm=bold term=bold ctermbg=black ctermfg=Blue

(Note: for the sake of readability I have finished all quotes)

I have tried inserting the JAKEHTTPS keyword in:

  • .java files
    • in comments
    • in code
  • .xml files
    • in comments
    • in code
  • .jak files (custom format that I created see below)

The only place that the keyword is highlighted is in the .jak.

Question: Why are these keywords NOT being highlighted in java code or xml code (and probably other code as well?

~/.vim/ftdetect/jak.vim:

syn region JakeSubtitle start=+==+ end=+==+
highlight JakeSubtitle ctermbg=black ctermfg=DarkMagenta

syn region JakeTitle start=+===+ end=+===+
highlight JakeTitle ctermbg=black ctermfg=yellow

Note: I created this thread but it has become too cluttered to be useful.

Best Answer

For standard filetypes the syntax tags are cleared before loading the filetype.vim syntax file
You can see the command,

syntax clear
in the begining of java.vim and xml.vim syntax files
Just change the lines in vimrc as follows,
au bufread * syn keyword JakeKeywords        Question TODO Answer JAKEHTTPS
au bufread * highlight JakeKeywords cterm=bold term=bold ctermbg=black ctermfg=Blue
This should work fine...