My Story With Neovim

December 07, 2024 04:13

I spend a lot of time editing text. I'm not 100% sure how many hours a week at this point, but most of my time at my day job is spent reading and writing source code and lately I've been coding pretty consistently in my spare time as well.

For most of my years spent programming, I looked at terminal editors like vim and emacs as "old school", "complicated", and "for try hards". Why spend so much time learning fancy shortcuts if most of my time is spent reading existing code? Wouldn't moving around with your mouse be just as quick? Wouldn't it be a heck of a lot easier? Surely the time you spend learning how to use these editors could be better spent on other things right?

I was wrong.

What changed everything for me was watching a YouTuber named The Primeagen. The way he moved around his editor and swapped between different files looked like complete wizardry. I knew as soon as I saw what he was doing that this was something I had to learn how to do.

He also had some solid advice for how to get started with vim; just learn the motions and keep your existing editor. At the time, I was primarily using Visual Studio Code for the majority of my text editing, and IntelliJ exclusively for Java projects. Thankfully both of these development environments (and as it turns out the vast majority of all other popular code editors) have plugins you can install to enable vim motions.

I kept using VS Code for a while to got used to using vim motions. It was kind of slow and annoying at first, but after some time I began to feel myself getting faster. Jumping around with my cursor began to feel natural. Swapping between modes with the escape key became familiar, getting more ingrained into my muscle memory.  Finally after well over a month of getting used to these motions I decided it was time to go all in on my new main text editor; Neovim.

When I first started working with Neovim, I tried using a "pre-configured" distribution for setting up the editor. After weighing my options, I installed NvChad because I thought the name sounded cool. It wasn't long before I wanted to add in more functionality to the editor, and the first thing I tried adding was GitHub's AI coding assistant Copilot. While I did eventually get this working, I didn't really understand how the plugin manager for NvChad worked. I was essentially searching around and blindly copy/pasting things into my editor without really understanding how things fit together. It didn't take much time fumbling around this way for me to decide that I needed a better approach.

So one Saturday afternoon when I had some time on my hands, I pulled up another video from The Primeagen and followed along as he set up Neovim from scratch. Some things in the video were a little outdated, but I was able to follow along and get my own configuration working. I liked having my own more minimal setup, and I was happy that I really understood how to extend the functionality of my editor.

As I installed more packages into my configuration, I discovered that most Neovim packages weren't showing the package manager I was using in their documentation. The configuration I had set up was using Packer, but most of the examples I was seeing online were using Lazy (not to be confused with the Lazy Neovim distribution). So I made an entirely new configuration and this essentially ended up being the configuration I'm still working with and tweaking to this day.

At this point, I've pretty much abandoned Visual Studio Code as an editor in favor of Neovim. I love how lightweight and fast it feels compared to a GUI based editor like VS Code. Loading files, searching for files, searching for text, and navigating around in an open project feels way faster, especially when I never need to lift my hands off the keyboard and reach for a mouse or trackpad. It also feels like a more consistent experience, since I can set up my own shortcuts and plugins through a configuration and have that configuration kept in sync between my work machine and my personal computer. All I needed to do was have my config pushed up to a git repository.

With that being said, I still prefer to use IntelliJ for Java projects at this point. While I've been able to replicate the features for fuzzy finding, linting, import management, and going to definitions that exist in IntelliJ, I haven't found a good solution for a debugger. I may at some point try to really learn jdb and just use that in a separate terminal window for debugging Java. Until then I'm sticking to what feels comfy. 

So with all that being said, I'm really glad that I decided to make the switch over to Neovim. I haven't fully replaced IntelliJ, but even my experience in that editor has been improved through this process now that I have vim motions under my belt. I would encourage anyone who's at all curious about learning vim to just try out vim motions for a bit in your existing workflow. Even if you don't end up going all in on a terminal based editor like Neovim, just having the ability to move around and edit text quickly without a mouse in any editor is something that's worth your time. Especially when you're someone that spends a lot of time editing text.