I have defined my own file types using vim. For example I have:
.classNotes
.reportJotNotes
.homework
These file types are defined in .vim
files:
~/.vim/syntax/homework.vim
~/.vim/syntax/reportJotNotes.vim
~/.vim/syntax/homework.vim
Many of these things have several of the same code in them. Ie they all have this for titles:
syn region JakeTitle start=+=== + end=+===+ oneline
highlight JakeTitle ctermbg=black ctermfg=Yellow
syn region JakeMasterTitle start=+==== + end=+====+ oneline
highlight JakeMasterTitle cterm=bold term=bold ctermbg=开发者_Python百科black ctermfg=LightBlue
Instead of having this in all three .vim
files I would rather have it in one file and then in each file could source it. How can I do this?
You can use :runtime! syntax/<common>.vim
Using :runtime
instead of :source
has the advantage that vim will search in all of the normal locations for syntax files so you aren't forced to keep all files in the same folder, and vim will even include any /after/syntax/...
files you might create in the future.
精彩评论