I want syntax highlighting for vim scripts in my latex document. So if I write

autocmd FileType c setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4

it should highlight this viml source.

I googled around but did not get any good result, as google does not understand what I want. So maybe it is my fault because I don't know how to use google, or it is googles fault because it is not able to understand me. Are there any packages/settings/foobar which help me to do this?

  • Maybe this could help you out? – timss May 16 '13 at 16:31
  • Have a look at this. – mrkva May 16 '13 at 20:42

Since vim scripts are not one of the the languages supported with a built-in analyzer in the listings package, you will have to:

  1. Write an analyzer for listings,
  2. Substitute another analyzer and tweak keywords (might the sh analyzer be adequate?),
  3. Find a highlighter that will substitute in Latex. Minted/ Pygments doesn't support vim scripts, but it might be easier to write your own support, or
  4. Switch to Context: Context's Vim module supports vim scripts; see https://tex.stackexchange.com/a/73109/175

For the fourth choice, in Context you might enter:


  autocmd FileType c setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
| improve this answer | |
  • I made a minor improvement in the context code. I hope that you do not mind. – Aditya Jun 16 '13 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.