DEV Community

Cover image for Ditch VSCode. Just use Neovim.
Oscar
Oscar

Posted on

Ditch VSCode. Just use Neovim.

Recently I came across a blog post (super awesome post by the way) about the everlasting text editor war: VSCode vs. Zed vs. every other text editor out there. It got me thinking: Why bother using all of these slow and inefficient text editors when you can just use Neovim?

JetBrains IDEs tend to be overloaded with tools that you don’t use in your day-to-day workflow, and VSCode is better, but it isn’t optimized for productivity (you haven’t experienced true ✨ productivity ✨ until you’ve experienced Neovim). Most other editors and IDEs have the same problem.

So, if you’re having problems with your current editor, whether it be speed, customizability, compatibility, or efficiency in text editing, Neovim is for you. Even with its reasonably steep learning curve (which can be greatly mitigated by using something like LazyVim), it is worth using.

And as I just mentioned, if you’re worried about compatibility, don’t be! Neovim is supported on Mac, Windows, and Linux; and if there’s a niche operating system that I’m unaware of, it’s likely supported on that as well.

A brief history of Neovim 📖

Before I get into exactly what Neovim is and why it’s worth learning, let me give you a brief rundown of its history.

Vi was created in 1976 by Bill Joy. Then, in 1991, Vim was created by Bram Moolenaar. Vim’s purpose can be found in its name: Vi IMproved. It was intended to be a better Vi. Finally, in 2014, Neovim was created. It is a fork of Vim, which makes it a “drop-in replacement that is 99% identical for basic usage” (Fireship).

As previously mentioned, Vim and Neovim are pretty similar on the surface, but one of the biggest differences between Neovim and Vim is that Neovim has a much larger community that tends to be much more welcoming to new features (Fireship). Past that, Vim and Neovim are pretty similar.

By the way, if you’re looking for something that gives a little bit more of an in-depth history, I would recommend watching Fireship’s video:

Speed 🏃

How fast is Neovim? Well, my startup time (with Neovim’s –startuptime command) using exactly 30 plugins is… 94 milliseconds. VSCode, on the other hand, with 0 plugins (for reference, VSCode calls these extensions) takes 4.5 seconds to start up for the first time after a boot, and 200 ms to start up any time after that.

A little disclaimer: It’s worth noting that the time Neovim takes to startup is a little bit skewed because I run 2-3 terminals inside my Neovim session. The total startup time including those 2-3 terminals comes out to about 900ms, which changes the output of Neovim’s –startuptime command to around 1 second. All that being said, you can interact with the editor before the terminals have finished launching, which is why I still consider Neovim to start in 94 milliseconds.

Of course, the time it takes for a text editor to start is not all that matters. The speed of the editor when you’re actually coding is certainly the most important part.

Figuring out what I could time here was… a pain, to put it lightly. There’s not really an easy way to time anything in Neovim – or any other text editor for that matter – (if there’s a plugin for this, let me know; and yes, I’m aware that I could try and make my own) and I can’t back up my assertion that Neovim is the fastest text editor by just saying “yeah dude, it’s pretty fast”. So instead of scrabbling for hard data, I chose to go the anecdotal route, and record a few videos of Neovim in action.

Here’s the first video. This first video is what’s called a Fuzzy Finder (you can read about the one I’m using here). Simply put, it’s a wickedly fast file finder that uses ripgrep to rip through your files (pun intended). I’m using Django’s repository as an example, which has a sizable 6799 files when I downloaded it, which was in mid March of 2024. In the video, I’ll be searching for a file path named sitemaps/views.py.

A little side tangent here: I know that there are a lot of plugins for modern IDEs today that can achieve performance that is somewhat similar to this, but as far as I know, there exists no plugin for a fuzzy finder in any modern IDE.

Pretty fast, isn’t it? The other feature that I’d like to show you are the language servers that I have installed for Python (you can configure these yourself, of course!) Here’s an example with Python when typing a simple print statement.

Also, for the audience members that aren’t familiar with what a language server is: it’s a tool that’s meant to “provide the language-specific smarts and communicate with development tools over a protocol that enables inter-process communication” (citation here). You can kind of think of it as Intelli-Sense.

Again, it’s pretty dang fast. If speed is an issue with your current editor, Neovim absolutely solves your problems.

Customizability 🧰

I can’t say most things about Neovim (or anything, for that matter) with 101% certainty, but the one thing that I can say is that Neovim is the most customizable editor you can use (with the only possible exception being Vim, Neovim’s predecessor). This might be a little bit of a turn-off for some people, as the quick “click, install, launch” procedure that VSCode and other editors offers is incredibly attractive. However, the customizability that Neovim brings to the table is certainly worth the extra effort.

And if you’re really desperate to use Neovim without configuring anything, you could always use LazyVim. That being said, I feel that LazyVim comes a little bit too close to being a VSCode clone. Don’t let my opinions stop you though! If you wanna use it, go for it.

Another quick side tangent on why I don’t like LazyVim: Neovim can not only be used as a text editor; it can also be used as a tool to help you understand your tooling (i.e. all of the plugins that you’re using). It’s a text editor first, of course, but there’s so much more to it than just editing text. LazyVim skips all of that, and it grants a more VSCode “vibe”. That’s just me though.

Anyways… back to customizability. Say you want to install a plugin to help you automatically format your code. Lucky you! There’s already a plugin for that. You’d install this with your package manager (I won’t get into that here, as there’s a lot of different options), and then you would create a new configuration file for this plugin inside /after/plugins/ (on a Linux-based system, every configuration file is under ~/.config/Neovim/.) Inside the file that you just created, you would configure the plugin using the programming language Lua (or Vimscript, if you’re above the age of 30 :) ).

Or, if you’re not down for writing 50 lines of configuration by yourself – which is totally understandable – then you can copy and paste the default configuration that most plugins have listed on their Github. And of course, you can customize the heck out of this config file! Once you’re done, save the file, and relaunch Neovim.

As you can see, Neovim is hands down the most customizable editor out there. Let me know if you don’t think so; I’d love to know why, and what editor you think is more customizable.

Steep Learning Curve 💹

Finally, I’d like to concede to one very good argument against Neovim: Yes, there is a steep learning curve. But is it worth it? Also yes! The steep learning curve primarily comes from Vim motions and modes; the core of Neovim's lightning-fast text editing. But instead of trying to explain why Vim motions are awesome, let me just show you.

Have you ever been editing a file in your favorite text editor, and you saw a character 10 lines above your current line that you wanted to edit? What did you do? Probably something along the lines of this:

Move your right hand off your keyboard (ouch, that’s the 36th time you’ve slid your wrist across your desk mat today), grab your mouse, click on the line (oops, you misclicked), click on the correct line, slide your hand back over to the keyboard only to realize that you set your cursor a few characters over from where you needed to be, then use the arrow keys to correct yourself until you’re finally at the desired location in your file.

Or, alternatively, you could just hit Esc + 10k + h + i. Cryptic? Certainly. Impossible to “decode”? Certainly not!

Let’s start from the beginning. By default, Neovim starts in Normal mode. This is where you’ll spend about 80% of your time. Directly editing text isn’t available in this mode, but that’s fine, because we now have the entire keyboard available for our upcoming Vim motions and commands (and additionally, most people are much more comfortable with these keys). No more stretching your hand across the keyboard to hit Ctrl + Alt + Shift + \ + Numlk!

But, for the sake of an example, we’re going to imagine that we started in Insert mode. This mode is basically your normal text editing mode. You can move around with arrow keys, type stuff in, remove it with the Backspace key… that’s really it. Hitting the Esc key will change your Vim mode to Normal mode.

So now what the heck does “10k” do? Well, now that we’re in normal mode, all of our commands are generally going to follow this pattern: Command - Count - Motion.

  • Command runs a… command.
  • ‘Count’ stands for how many times you want to do that command or motion. For instance, pressing ‘k’ (which is a motion, because it moves the cursor) in Normal mode moves your cursor up a line.
  • Motion, as previously mentioned, refers to anything that moves your cursor. So, pressing 10k (Count, then a Motion) moves your cursor up a line 10 times.

Pretty simple, right?

Now we just have h and i left! h is a motion, and it simply moves your cursor to the left once. i is a little bit weirder, as it puts you back into Insert mode. But nevertheless, once you’re here, you’re free to edit your text as you please.

This may sound complicated… but in my opinion, it’s totally worth the effort of learning. Additionally, you’ll get to a point where this is just second nature. I personally don’t even think about doing these motions anymore.

Plugins for Vim Motions 🔌

I would like to make one final note. If you’re worried about how hard it’s going to be to transition to using Vim motions in your day to day life, I highly encourage you to install a Vim motions emulator. These emulators allow you to simulate an actual Neovim environment – with fully functional Vim modes, motions, and commands – and disable/enable it with the click of a button.

I know that VSCode, Atom, and Sublime have one, and I’m pretty sure that all JetBrains IDEs do as well. I was able to pick up on Vim motions pretty quickly, and I ended up transferring over to Neovim in about a week. You might be able to learn Vim motions in a day, or it might take you a few months. Either way, these emulators can really help you transition over.

To conclude… 🎁

Give Neovim a try. I hope this post encourages at least one of you to install it, or at the very least, install a Vim motions emulator.

If you’d like to try my Neovim config, you can find it here: https://github.com/kurealnum/nvimconfig

One final message: I know that I only scraped the surface of Neovim. There’s so much more to cover. If you have any ideas or questions, feel free to leave a comment!

Top comments (0)