My vim + tmux fanaticism | bioinformatics
This probably shouldn’t be tagged as “bioinformatics”, but I am asked by computational biologists about which IDE I use more often than I’d expect—sometimes by newer programmers who are looking for advice, and sometimes by experienced programmers who are just making small talk. And whenever it’s an experienced programmer, they usually give me a (disappointed? disapproving?) shake of their head when I say that I do everything in tmux + vim.
So I present a defense of why this setup is great for bioinformatics development (where most development is done on clusters with the aim of analyzing tons of data):
- It’s truly mouseless and fast. This is the main selling point of vim, so no surprises here: coding and navigation are extremely fast. But tmux makes development fast even outside of coding. I usually set up my tmux window such that the left half of the screen is code, and the right half is split into two panes: the upper to be used for displaying data/poking around directories, and the lower to be used for running code and seeing results. This means it is extremely fast to flip between opening data, running stuff/viewing results, and modifying code—all on the same screen and without using your mouse.
- You can use this setup on your phone. To be clear, I am not suggesting this as a normal mode of operation. But you can edit scripts, run stuff, or check on jobs if it’s urgent and you’re away from your computer or in a pinch (e.g., my laptop once broke while I was in the middle of nowhere and had to run something). You can use an app like Terminus—vim and tmux work the exact same.
- It’s always there and fully contained on the server. Back to the incident where my laptop broke in the middle of nowhere: because I was in the middle of nowhere, I could not get my laptop repaired. So I borrowed some of my friends’ laptops for a few hours at a time, and no setup was required. I just had to ssh into the cluster and everything was there. And if you move machines, you just need to copy your .vimrc and .tmux.conf and you’re good to go.
- You can easily navigate and save multiple states. If you detach from a tmux session for the day, you can come back and everything is exactly as you left it—no need to reopen files and renavigate to directories. You can also easily save and flip between different terminal contexts for different tasks (e.g., you can use one window for code development, and another window for running benchmarking tasks in the background).
- It can make coding more fun. Ever feel bored of whatever you’re programming? Just Google new vim tricks and suddenly it’s exciting again.
- It’s coding in zen mode. There are absolutely zero distractions. Sure, you can make other GUIs sparse, but something about seeing literally only code and data makes it easier for me to focus.
- There are plugins for everything. My vim configuration is actually pretty sparse. But I am told you can get pretty much any modern IDE feature through plugins (and those who get into vimscript can add and customize any feature they want).
- Ranges let you quickly manipulate multiple files or blocks of code at once (e.g., for cleaning up debugging statements). Ranges can be very powerful, though I have to admit that my most commonly used application is not that fancy. Whenever I add debugging statements, I tag them with a comment that has an unusual string (e.g., my initials “MKL”). This means that once I’m done debugging, I can use ranges to delete all of my debugging code with one command.
- The quick fix list makes error correction fast. You type :make, and suddenly you have a super fast way of seeing your compiler errors and either jumping through them or modifying/fixing multiple errors at once. Or you :grep something, and you can quickly navigate or manipulate all instances of an expression within a directory.
- vim macros can also be used to reformat data. vim macros allow you to repeat the same set of commands an arbitrary number of times. I’ve found this to be useful not just when coding, but also when I have to reformat data or temporary files. I have tried using macros in other environments that support vim keybindings, and it never seems to work properly.
When this setup wouldn’t work:
- Notebooks: When I said this setup is great for bioinformatics, I was being unfair to the large part of the community that writes R or trains neural nets in notebooks. I’m biased since I only write C++ and Python scripts. But viewing and editing notebooks directly in this setup is not possible.
- AI assisted coding: I’m not too familiar with this since I don’t code with AI. There is a Copilot vim plugin, but I am not sure how smooth it feels compared to using something like VS Code, and there are probably some models that are harder to get working with vim.
I think the main drawback of this setup is the learning curve. I had a relatively gentle introduction to vim from playing video games that use vim key navigation. I was also forced to learn either vim or nano very early on, so I didn’t really mind the beginner pains because the alternative was (in my opinion) much worse. But it would probably be very annoying to get up to speed for someone who already has an established workflow.
Of course, it goes both ways: I have tried using other IDEs after people insisted it would make development much faster, but I am too set in my ways to really give them a fair chance. The only thing I have been tempted to try recently is emacs, but that will probably end up being its own whole saga.
August 1, 2024