Reputation: 2921
Ive got file that uses java code blocks, Is it possible to tell vim in syntax file to import java.vim
syntax file for a whole region ?
Example:
syn region javaCode start="<Java>" end="</Java>"
hi link javaCode source ????
Upvotes: 0
Views: 422
Reputation: 172748
The easiest is to just
:set syntax=java
and focus on the Java part. However, if you want to overlay the Java syntax in your own syntax file, :syntax region
is the way to go. :help :syn-include
has the details:
:syntax include @Java syntax/java.vim
:syntax region myJava start="<java>" end="</java>" contains=@Java
PS: Since the command is complex (but that's okay in syntax scripts that include another syntax) and hard to remember, I've written the SyntaxRange plugin to make setting up such regions easier. For your example, it'd be this call:
:call SyntaxRange#Include('<java>', '</java>', 'java', 'NonText')
The plugin is meant for occasional, ad-hoc use. If you write your own syntax script, I'd avoid this dependency and directly use the syntax commands from above.
Upvotes: 2