v6/site/posts/2020-05-21-switching-to-vim.md

33 lines
5.1 KiB
Markdown
Raw Normal View History

2022-12-10 18:15:32 +00:00
```
title = "Switching to Vim"
tags = ["editors"]
date = "2020-05-21 18:22:42 -0400"
short_desc = "How I went about joining the cult of Vim."
slug = "switching-to-vim"
```
At the beginning of last summer, for reasons that I can no longer recall, I set a goal for myself to learn Vim over that summer. Now that summer is over and almost here again, I wanted to reflect on that process and whether I achieved my goal. By no means have I mastered Vim or am a Vim expert, but I feel reasonably proficient. I use Vim itself on the command line and in GUI form, as well as Vim bindings/plugins in all my IDEs. It has gotten so strongly ingrained into my muscle memory that I now find myself hitting ESC to exit insert mode in text boxes in my web browser and typing Vim commands into word processors.
<!-- excerpt-end -->
In order to force myself to try and become more proficient and get the keybindings worked into my muscle memory, I made the decision fairly early on (shortly after I felt comfortable with the basics of text navigation and editing) to switch all of my IDEs to use Vim keybindings/plugins and use it full time.[^1]
[^1]: Since I've gone all in on Vim, I also switched to rebinding the Caps Lock key to Escape on all my computers and keyboards. But I don't just use it in Vim, I use the Caps Lock key as Esc in macOS for everyday things, and even games. A side effect of which has been I now find it infuriating to use computers where Caps Lock has not been remapped Escape because I press it instinctively and end up changing case and getting confused all too frequently.
I briefly considered using Vim independently of any IDE and relying entirely on plugins and command line tools to provide the rest of the functionality of the IDE, but I didn't end up doing this for a couple reasons. First and foremost, a great deal of the functionality the IDEs provide is not easily replicable. Secondly, I didn't want to have to learn even more things simultaneously. I wanted to stay focused on learning Vim, and adding a whole new set of tooling on top of that would distract from my main objective.
While I use Vim independently on some things, for most of the projects I work on both personally and for my job, I use an IDE. The ones I use most frequently are RubyMine for work and Xcode for personal iOS projects (and occasionally others in the JetBrains family, like IDEA and WebStorm).
The JetBrains IDEs sport a truly wonderful first-party plugin called [IdeaVim](https://github.com/JetBrains/ideavim) which emulates a great deal of Vim. In my experience using it the only feature of Vim that I've found IdeaVim does not also support is user-defined text objects (although all of the ones I use in Vim itself are supported already by IdeaVim).
In my experience using it, I have not encountered a single feature of Vim that IdeaVim does not support (granted, I'm not doing anything that crazily complicated).
For Xcode, there is a third-party plugin called [XVim](https://github.com/XVimProject/XVim2/) which performs a similar function to IdeaVim. Unfortunately, XVim is nowhere near as full-featured or as comprehensive as IdeaVim. The feature I use most frequently which it doesn't support is using the `.` command to repeat a command involving a text object (e.g. `ciwFoo<ESC>`). It either crashes Xcode or performs some sequence of actions that seems to bear no relation to my actual command. In environments where it is supported, I've found it very useful for pulling out bits of text that I recently deleted. Another of XVim's shortcomings compared to IdeaVim is the fact that, in order to use it, you must have a copy of Xcode that has been re-codesigned with your own self-signed certificate. When Xcode is signed by Apple, it does not load third party plugins. This means I end up having multiple copies of Xcode on my disk (since I prefer to keep the Apple-signed ones and an old version around just in case. I currently have 4 copies of Xcode, for a total of 73.76 GB on disk). I've considered switching to AppCode, JetBrains' IDE for iOS/macOS apps, but on the brief occasions I've tried it, it's been rather lacking compared to Xcode and so not worth making the switch.[^2]
[^2]: I mostly remember to not press `.` in normal mode. Xcode only crashes a couple times per week.
For the projects I work on which I don't use an IDE for (primarily Elixir projects), I use [MacVim](https://github.com/macvim-dev/macvim) with an assortment of plugins. I use [NERDTree](https://github.com/scrooloose/nerdtree) as a file manager, [fzf](https://github.com/junegunn/fzf) for quickly switching files, [coc.nvim](https://github.com/neoclide/coc.nvim) for integration with language servers (including Elixir and TypeScript), and a few other small plugins.
At this point, I could go on about how switching to Vim has vastly increased my productivity and turned me into the mythic 10x developer. But that isn't true. I can only imagine switching to Vim has made little, if any, difference to my efficiency. Sure, when I'm typing or changing large sections of text, I feel faster. But the fact is, the vast majority of the time, I'm not doing that. The bottleneck is not my hands or my keyboards, it's my brain. And Vim can't magically change that.