sh.vim

Have you ever been frustrated with perfectly valid bash syntax being highlighted as incorrect in vim? Like this:


#!/bin/sh
foo=$(ls /tmp)

$() is a perfectly valid, nay preferred substitute for backticks. The problem is that vim is deciding this is pure old bourne shell instead of whatever else we’d like it to be. If you change the shebang to #!/bin/bash and re-edit the file, then the error markings go away. But maybe you’re writing for the nebulous POSIX shell, not bash nor sh. Or maybe you just don’t care and you don’t want vim complaining that you’re using bashisms even though your shebang says sh. You can set the defaults so that it reflects your system and preferences. It’s all there in :help sh.vim.


Leave a Reply