Vimrc: how to reuse code and definitions for different file types?

I have defined my own file types using vim. For example, I have:

.classNotes
.reportJotNotes
.homework

      

These file types are defined in files .vim

:

~/.vim/syntax/homework.vim
~/.vim/syntax/reportJotNotes.vim
~/.vim/syntax/homework.vim

      

Many of these things have several of the same codes in them. Those. they all have this for headers:

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=black ctermfg=LightBlue

      

Instead of having it in all three files .vim

, I would rather have it in one file and then I could load it in each file. How can i do this?

+2


a source to share


1 answer


you can use :runtime! syntax/<common>.vim



Using :runtime

instead :source

has the advantage that vim will look in all the normal places for syntax files so you don't have to keep all the files in the same folder, and vim will even include any /after/syntax/...

files you might create in the future.

+4


a source







All Articles