开发者

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

开发者 https://www.devze.com 2022-12-30 03:18 出处:网络
I have defined my own file types using vim.For example I have: .classNotes .reportJotNotes .homework These file types aredefined in .vim files:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消