Syntaxless Vim

Posted on Dysfunctional Programming 2019-06-08

My main editor, for well over a year now has been Vim. For a number of years before that I tried to use it full time but for one reason or another it didn’t fully stick. Now I am more productive and faster in Vim than anything else[0].

There are numerous blog posts and articles all over the web already talking about how to use Vim and how people configure Vim, so I won’t repeat what’s already out there. I want to write about a very specific aspect of Vim: syntax highlighting. I don’t use it.

It boils down to the fact that I highly value code clarity. I obviously hope to write bug-free code as much as possible, but I also focus on how readable it is. Not just for the benefit of others but also for my future self. Aside from aesthetics I also consider using clearer algorithms or patterns particularly when the language gives you the choice. If it means the code is actually slower (within reason) then that’s preferred. This also affects my choice on both languages and tools[1]. Without syntax highlighting, I think it forces you, even more than usual, to properly read and review code.

Without highlighting, Vim is faster because it has less to do, noticeable on very large files. When you open a filetype that doesn’t already have a syntax highlighting definition, oh well, your Vim setup is leaner and simpler.

I still have a colourful and pretty Vim interface (using and it’s only the syntax that is disabled.

If you want to get rid of all colour, you can tell Vim your terminal doesn’t support it:

:set t_Co=0

and disabling syntax highlighting is a simple as:

:syntax off

Vim with base16 colours and airline

I think anyone reading this should try disabling it. It of course takes a little while to adjust but when you do, you kind of forget about it.

This was clearly seen as a viable use case in Vim (although maybe there were other historical reasons for this), but in all other text editors where I have tried to do this there wasn’t an option and it took a workaround. The last time I checked (2018 or earlier) for Atom, Visual Studio Code and Sublime Text you either had to have a syntax definition where all colours are set the same or override the filetype to plain text. I think this is a shame, as it is worthwhile to to at least try this; personally for me, it works really well.

0 Vim key bindings for other editors just don’t cut it. There’s still a lot of functionality that can’t be accessed via the keyboard. Being able to run in a terminal, over ssh, in a container or a VM is also very handy.

1 As an example, Perl has been called a write-only language but I think context sensitive variables such as $_ actually make the code clearer and more readable.