Vim (7.0.17) does not check correctly if loop ender-like words are actually loop enders. Such words (e.g. 'fi', 'done') are always interpreted as loop enders if the word is not preceded and succeeded by something alphanumeric. An example: #!/bin/bash while true ; do echo done! done In the above the 'done' after 'echo', followed by an exclamation mark, is highlighted as the end of the while loop, while the correct 'done' is highlighted as a duplicate 'done'. Another example: #!/bin/bash if [ "$1"x -eq "-MyServer"x ] ; then ssh santa@korvatunturi.fi fi In the example above, the 'fi' following the dot is highlighted as the ender of the fi -loop, and again the correct 'fi' will be highlighted as if it were wrong. However, these are highlighted correctly: #!/bin/bash if true; then echo suomifi fi #!/bin/bash while true; do echo doneIsAll done Reproducible: Always Steps to reproduce: 1. Try the examples above. 2. Look at the wrong color highlighting 3. cry (a little) Actual results: In both examples something before the actual loop ender is detected us such. Expected results: Vim should detect the loop ender correctly.
Well, one easy way around this is to quote the offending line, like so: #!/bin/bash if [ "$1"x -eq "-MyServer"x ] ; then ssh "santa@korvatunturi.fi" fi Of course, that isn't a real fix. However, this is really a bug in the syntax/sh.vim script provided by upstream, so I'm going to close this bug as UPSTREAM. If you could report this bug to the upstream vim maintainers, I'm sure they'll come up with a good fix. Here's their instructions for submitting a bug report (taken from their FAQ): 2.6. Where can I report bugs? First collect the required information using the following command: :source $VIMRUNTIME/bugreport.vim Now send the resulting text from the above command to the bugs@vim.org e-mail address. The Vim Development mailing list (see above) is a good place to discuss general bugs. If the bug you find is with syntax highlighting or some other "added feature" (i.e. not directly programmed into vim), attempt to inform the maintainer of that feature. For more information, read :help bug-reports When a patch is made to fix this, I'll make a new gentoo release of vim.