2

Hmmm. Good question. Is there really not a Vim mechanism for dealing with this? I can't recall seeing one. If there's not I was able to leverage Bash semantics to get something to work. I'm using sort as an example command as it's a common filter and easy to make fail... Valid invocation: :%!sort -n 2> /dev/null || cat % Result: the buffer contents are ...


1

There are examples in :help syn-include. There is also an extended example present in :help sh-embed for awk, which uses a recipe like this: You may wish to embed languages into sh. I'll give an example courtesy of Lorance Stinson on how to do this with awk as an example. Put the following file into $HOME/.vim/after/syntax/sh/awkembed.vim: > " ...


1

In general :syntax include should be used. Usually in the main syntax there should be "hooks" -- something that clearly defines begin and end of the foreign syntax block. In your case it would be tricky to identify why part a should be bash while part b html. For example in asciidoc(tor) syntax there is a clear definition of the foreign syntax: [...


Only top voted, non community-wiki answers of a minimum length are eligible