简体   繁体   中英

Proper way to create a syntax file in vim that depends on another syntax file

I am currently creating a Vim syntax file for WordPress and have it inside a file called wordpress.vim

All WordPress files are PHP files but not all PHP files are WordPress files.

My wordpress.vim syntax file depends on the php syntax file. So I have included it using the following line

so <sfile>:p:h/php.vim

My question is what is the most elegant way to include all PHP syntax into WordPress syntax and where should I put the the new wordpress.vim file that I have created.

The right location for your syntax file should be:

~/.vim/syntax/wordpress.vim

You should take a look at $VIMRUNTIME/syntax/cpp.vim for what I assume is the correct syntax:

if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

" Read the C syntax to start with
if version < 600
  so <sfile>:p:h/c.vim
else
  runtime! syntax/c.vim
  unlet b:current_syntax
endif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM