Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com May 16 '13 at 19:51

This question came from our site for professional and enthusiast programmers.

    
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
add comment

1 Answer

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 http://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
share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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