I would hate to think that my work as a writer could not be done without a direct dependence on strip-mined coal. How could I write conscientiously against the rape of nature if I were, in the act of writing, implicated in the rape?
Preface
I used to think I was cool. In particular, I used to think my setup was cool. Arch Linux running i3 running urxvt running tmux running Neovim. All this running… and for what? Better UX? Quality of life? Efficient workflow? Noble purposes, and yet sometimes it’s too much and I want it to stop.
I’ve always been a minimalist when it comes to software, yet today my idealism is not strong enough. I want more. And less is more, right? So today I’ve taken yet another step in this hopeless path I know many of you walk. Because I can’t help myself. Because I resent every program, every foreign line of code, every third-party tool I’ve come to depend on. Arrogance demands perfection, while humility demands austerity. You and I know the perfect tool, the most austere tool, is no tool at all.
If I have started my essay by reminding you (and myself) of old ideals it’s because I need your mind open. Sure, the thesis proposed in this essay is outrageous, unthinkable; it was for me too. But I was shunned for living in the terminal, for using Vim, and for coding in C by closed-minded engineers before, and I’m sure that if you sympathize with my words, then you’ve met a similar opposition before.
So keep your mind open, and let me tell you of my journey. My journey of ditching syntax highlighting for good.
Origins
There is a semi-popular article by Linus Åkesson arguing against syntax highlighting, which caught heavy flak on both Reddit and Hacker News. Here is part of Åkesson’s conclusion.
Syntax highlighting doesn’t improve legibility. It encourages you to skim through code rather than understand it. It makes you focus on syntax errors rather than real bugs, and it gets in the way of your learning.
I do think the arguments made in that article are weak (mind you, so are most arguments in the opposition). Even so, I couldn’t help but wonder if there was some truth in the conclusion. This idea lived in my mind rent-free for a few months before I decided to do something about it.
First I did some research. It seems very few programmers have come out to speak against syntax highlighting, and those that do make identical arguments to Åkesson. I’m here less to argue and more to describe my experience, as someone who was extremely skeptical about renouncing my beautiful Gruvbox colourscheme that had taken some time to setup and customize in Neovim.
I’m here to tell you that giving up syntax highlighting, along with other niceties offered by my text editor, was one of the most liberating experiences of my programming career.
Experience
It feels weird. Like looking at your code through a cloudy window. After a short acclimatization stage, I started seeing some benefits.
Fuck syntax
Credit to Åkesson, he hit the nail on the head with this one. I found myself worrying less about syntax and more about semantics. This alone would have made the switch worth it.
Before, I would code in a very OCD way: closing every bracket and quote, giving types to every variable, making sure function declarations have the right arguments, etc., even before I knew what I was going to implement! Think about it: I was spending brain cycles in keeping code syntactically-correct rather than in solving the problem at hand. Now why would I do that? I suspect it’s because I was visually punished for breaking syntax: the colours would all be messed up, and the LSP would throw a million diagnostics my way. Turned all of that shit off and now I feel comfortable writing pseudo-code first, and slowly tweaking it until the compiler is happy.
This approach is, I think, superior because it keeps the separation between writing and editing. We are comfortable with diagnostics and highlighting flaring up as we code, but imagine how annoying it would be to have the writer and the editor working at the same time!
Writer: “The quick…”
Editor: What do you mean “the quick”? “The quick” what?
Writer: “…brown…”
Editor: Quick and brown? Is it the dump you took this morning?
Writer: “…fox…”
Editor: Okay yeah, you know what? Leave it at that. I’m done for the night.
Writer: Yeah, fuck you too.
Fuck dependencies
Syntax highlighting is hard. Vim does it by using regexes no one
understands (run :view $VIMRUNTIME/syntax/c.vim to get
a taste). And if you have studied any formal language theory you
know that 99.99% of real-world languages cannot be parsed by
regexes, so this is nothing more than a best-effort solution.
I thought the LSP and Tree-sitter were the answer. But, as someone who has implemented a language server (and attempted to write a Tree-sitter grammar), let me tell you: these are complex pieces of software compared to the task at hand (coding) and you should think twice about having them as dependencies. I’m not convinced that the incremental building of the syntax tree is something worth having anyways (not that it works perfectly all of the time).
You might as well go full VSCode if you don’t care about minimizing the complexity of your text editor, right? With the amount of features I’m using now, I’m convinced that if Neovim were to disappear I could, at least in principle, build a text editor that would fulfil almost all of my needs. And that feels really good.
Fuck aesthetics
Good for you if you think your editor looks cool. There is something fun about knowing you looking like a hacker when you open your laptop in a café or a train to do some work. Fun is an underrated motivator for all, but especially so for easily impressionable beginners.
However, I no longer think code needs to look dapper. It’s just words, and colour is little more than a distraction.
Other disposables
Line numbers
Get rid of line numbers, for fuck’s sake. I don’t know who convinced us that they were useful, but fuck that person. If I want to go to line number 77 I can do that with 77G in Vim, but I don’t need to see the number.
Vim also has relative line numbers which I used to have on, but to be honest I barely used them to jump around the screen as you are supposed to. I can see how you might find them useful though.
Diagnostics
I’ve talked about how annoying they are already. Turn them off.
I would say to turn them back on when you want to check for bugs, but at that point, you might as well run the whole project through the compiler or a linter. These days you can integrate those to your editor so you can jump to the problem locations immediately (check out the compiling section in the Vim user manual).
Status Line
My status line in Neovim used to have:
- What Vim mode I’m in.
- Filename.
- Whether the file was modified.
- Filetype.
- Line and column number.
- Line number as a percentage.
All but one of these I can get by using the CTRL + G command, and I don’t find myself using it very often anyways. So, the status line is essentially useless.
Caveats
I code mostly in ANSI C these days, which is a fairly unforgiving language with great tools for static analysis. A looser interpreted language, like Javascript or Bash, may benefit from syntax highlighting as a way to catch syntax errors that may actually get pass a forgiving interpreter. And something horrible like Markdown, where every utf-8 sequence is valid, practically mandates good syntax highlighting, lest you forget a closing asterisk or something.
I’m also talking about my experience building software rather than maintaining it; I think these are two very different things that require very different tools and skill sets. If you are mostly writing code I think syntax highlighting does more harm than good. However, if you are mostly reading and jumping around code, some colour might make things smoother. You may want to look for semantic highlighting and other tools like text folding and language servers (sometimes there is nothing like a good language server with support for “go to definition”).
Having said all this, notice that syntax highlighting that gets updated as you type is overkill for the applications above. I would like to see support for highlighting that gets updated on demand. Personally, I have a little keymap in Neovim that switches between my minimalistic ultra-focus default mode and a more standard setup with highlighting on.
Conclusion
The perfect tool, the most austere tool, is no tool at all. Failing that, a homemade concoction is close enough. Anything larger requires a lot of skill—without skill it will cause more problems than it solves. So do yourself a favour and don’t need too many things. Certainly don’t need something just because everyone else seems to need it (resisting such impulses is good practice for fighting against marketing).
Try coding without syntax highlighting. If nothing else, take it as an opportunity to talk to the programmer inside you, to find out what they truly need, what makes them happy. You’d be surprised; I know I was. Turns out, my inner programmer doesn’t need a slick window manager or a fancy terminal emulator. He definitely doesn’t need AI sucking all the fun out of everything. From what I can see, all he really needs is a simple UNIX environment running a clutterless and colourless editor with Vim keybindings, optionally a couple of books, and maybe some wine or beer.