Syntax highlighting has recently been enabled for our site (thanks!). However, Google Prettify doesn't support Vimscript out of the box. What can we do to remedy this? If we can give SE a good Vimscript plugin for Prettify without too many dependencies, we might be able to convince them to use it.

  • Is there an existing, good quality plugin?
  • Is there an existing, reasonable plugin that we can fix up?
  • Or, should we write one ourselves?

Thoughts on how to proceed? Volunteers, anybody?

  • You say it is enabled: How do I use it? May 2, 2016 at 6:44
  • 1
    @KarlYngveLervåg What is syntax highlighting and how does it work? essentially, you have to provide syntax highlighting hints (<!-- language: foo -->). Tags like vimscript-python and vimscript-lua have python and lua highlighting applied by default.
    – muru
    May 2, 2016 at 6:58
  • Can the work don in the external extra handlers library just be submitted to the upstream Google Prettify project so that proper language support lands upstream from SE? That seems like the best long term approach rather than having SE do something special.
    – Caleb
    May 14, 2016 at 10:08
  • @Caleb long term, I'm hoping SE will switch to Highlight.js, making all this redundant. Short term, it depends on a) how active the Prettify maintainers are, b) how active SE are in pulling updates from Prettify and c) how active SE will be if we ask them to include a single extension.
    – muru
    May 14, 2016 at 10:52

2 Answers 2


I created a user script for loading the Vim Prettify extension from Nobe4's answer. It's available on GitHub (the repository being vi-se/PrettifyExtender). It enables Vim highlighting by default on:

  • the main site,
  • here
  • and on other SE sites for posts with tags containing vim.

And I created an organization on Github for this site, along the lines of https://github.com/askubuntu, for scripts we develop for our site. Do join in, anybody else interested in administering it!

Please do test the Prettify extension with or without this script. I have looked over a few posts here, and on SO and AU, and it seems OK. If no major issues turn up, we can ask SE to include it in their set of extensions. Hopefully, they'll either include it or switch to Highlight.js. In any case, we should be fine. :)


  • This is great. It would be a really nice feature to have this. Is there anything we can do at this point to entice SE to use it, or do we just have to sit back and cross our fingers?
    – Tumbler41
    May 6, 2016 at 14:09
  • @Tumbler41 I intend to ask them to include this once it's been run for a few weeks, ironing out any problems.
    – muru
    May 7, 2016 at 12:55

Here are multiple options found while browsing:

The common parts are nearly the same, thus, we may want to start from them and create some tests.

I don't know how we can do this, but I'd be happy to help.

In the meantime I've created a codepen for testing: here.

The code used is simple and straightforward, I think it should be a good starting point if we want to improve on it. (But actually I don't think we need more than that).

Maybe it's worth creating a repo or gist for discussion/testing, but I'm feeling that we are not missing a lot (maybe regex) from the existing configuration...

  • I made a few changes to that (dunno how codepens work, do you see changes I make, or are they local to me?): made keywords and literals case sensitive, s/ehon/echon/, added setlocal, setglobal, map's un and clear variants, added v:true, etc. to literals (the Special values). Thoughts?
    – muru
    Apr 20, 2016 at 11:59
  • I think it's local, you can send the new url, I'll update the message, or we should find a proper way to update this ...
    – nobe4
    Apr 20, 2016 at 12:43
  • Thank goodness I had the sense to add those changes to Github and make a PR: github.com/hail2u/google-code-prettify-language-handlers/pull/2.
    – muru
    Apr 20, 2016 at 12:48
  • 3
    He merged it just now! github.com/hail2u/google-code-prettify-language-handlers/pull/…
    – muru
    Apr 21, 2016 at 2:12

You must log in to answer this question.

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