I'm playing with Vim highlight, so I made the following (syntax.vim
):
hi Comment ctermfg=DarkGray
hi LineNR ctermfg=DarkGray
hi CursorLineNR ctermfg=Red
hi String ctermfg=Gray
hi PreProc ctermfg=Brown
syn match MyOp /+/
syn match MyOp /-/
syn match MyOp /*/ containedin=comment contained
syn match MyOp /\// containedin=comment contained
syn match MyOp /&/
syn match MyOp /:/
syn match MyOp /\./
syn match MyOp /=/
hi MyOp ctermfg=LightBlue
syn match MyBrakets /</
syn match MyBrakets />/
syn match MyBrakets /(/
syn match MyBrakets /)/
syn match MyBrakets /{/
syn match MyBrakets /}/
syn match MyBrakets /\[/
syn match MyBrakets /\]/
hi MyBrakets ctermfg=Yellow
syn keyword MyNSutl utl
hi MyNSutl ctermfg=Gray
syn keyword MyNSmmi mmi
hi MyNSmmi ctermfg=DarkBlue
syn match MySend /send_\w*/
hi MySend ctermfg=Red
syn match MyGet /get_\w*/
hi MyGet ctermfg=Magenta
syn match MyPrint /print_\w*/
hi MyPrint ctermfg=Gray
syn match MyMPI /MPI_\w*/
hi MyMPI ctermfg=LightGray
I was testing it with a single file, while in Vim with my .cpp file open I did so syntax.vim
and the magic happened. So far so good.
Next step was to use it in the session I was working, Vim -S session.vim
to open some files in split view, and so syntax.vim
. Problem. Syntax applies to just one file, current split. So I have to repeat that to all files - not good.
After some googling I found that correct way to proceed was to rename it to i.e. cpp_my.vim
and put in ~/.vim/ftplugin/myplugin/. Did that, and it workds partially, some settings don't get applied. Then I went to Vim doc section 41.11 Writing a plugin. Things are getting complicated and here I'm.
The hack I did isn't general purpose, its just for the project I'm working these days. So making it a plugin don't smell good to me.
So in order to use it, the best approach is to manually so syntax.vim
to each file? Or is there some clever alternative?