VIM syntax highlighting is done via a Syntax file. Go into VIM and type in :echo $VIMRUNTIME
. This will tell you the VIMRUNTIME
directory. In that directory, there's a directory called syntax
. Inside that are the syntax definitions. There's a file called sh.vim
that contains the definitions for BASH, Kornshell, and Bourne shell.
Take a look around line #400 of the file, you'll see something like this:
" Special ${parameter OPERATOR word} handling: {{{1
" sh ksh bash : ${parameter:-word} word is default value
" sh ksh bash : ${parameter:=word} assign word as default value
" sh ksh bash : ${parameter:?word} display word if parameter is null
" sh ksh bash : ${parameter:+word} use word if parameter is not null, otherwise nothing
" ksh bash : ${parameter#pattern} remove small left pattern
" ksh bash : ${parameter##pattern} remove large left pattern
" ksh bash : ${parameter%pattern} remove small right pattern
" ksh bash : ${parameter%%pattern} remove large right pattern
It is in THIS section that defines the patterns and whether they're legal or not. You'll need to define a region that looks like this:
if exists("b:is_bash")
Here be dragons
endif
Actually, I see one farther down on line #423 in the latest version of the sh.vim
file, so you don't have to define your own.
Now, all you have to do is replace the Here be dragons
section with something that defines the syntax you want to show as not an error. I don't know enough of the VIM syntax to tell you. However, it doesn't look all that complicated. Backup the old sh.vim
and have some fun. Believe it or not, it's all documented right in VIM. I've modified the syntax files for Perl and Python without too many issues.
you can also go to https://vim.svn.sourceforge.net/svnroot/vim/vim7/runtime/syntax/ and see if there's a new sh.vim
file that might include the syntax fix you need.
You can also report the problem to the VIM project and let them know about the issue. They're pretty good about fixing things like this, and then you can go download the latest fix at the Subversion URL above.