1

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

\begin{lstlisting}
autocmd FileType c setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
\end{lstlisting}

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?

2
  • Maybe this could help you out?
    – timss
    Commented May 16, 2013 at 16:31
  • Have a look at this.
    – mrkva
    Commented May 16, 2013 at 20:42

1 Answer 1

1

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:

\usemodule[vim]
\definevimtyping[VIM][syntax=vim]

\starttext
\startVIM
  autocmd FileType c setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
\stopVIM
\stoptext
1
  • I made a minor improvement in the context code. I hope that you do not mind.
    – Aditya
    Commented Jun 16, 2013 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .