DEV Community

anes
anes

Posted on

An opinionated article about vim

Introduction

I have now been using vim and neovim for almost a year. In that time I built a lot of experience with the IDE, which I wanted to share with people thinking about making the switch.
This article will mostly just go over why I like vim, but I'll also be talking about some disadvantages.
When showing code to use as an example of editing, I'll be taking code from my own Redmine plugin: gnosis.

Super fast code navigation

The most obvious and most talked about point is how fast you can navigate code with vim. There are a lot of keybindings used for jumping around code. One example would be following:



protect_from_forgery except: %i[github_webhook_catcher semaphore_webhook_catcher]


Enter fullscreen mode Exit fullscreen mode

Now if I want to remove the github_webhook_catcher from the protect_from_forgery statement, I would go following steps (assuming my cursor is somewhere completely random): :4 WWW db does the job. Here is a video of how that might look:

Video of text being deleted, vim style

There are a lot more keybindings and tricks that improve your speed. If you have trouble memorizing them all, this cheat sheet was A-tier.

Extreme configuration

A personal favorite is how much you can personalize vim. Everything is customizable, from your background color to very specific keybindings. One example of that would be my own .vimrc.
As someone who gets irritated as soon as something tiny is wrong with their code editor, the ability to customize everything was a very big bonus.
Currently I am using nvchad with my own nvchad config, which makes for a beautiful code editor:
Screenshot of my nvchad dashboard
Screenshot of nvchad with open code

Very good plugin system

(Neo)vim supports plugins, which make your code editor much better. You need a faster way to comment stuff? Sure, here is nvim-comment. Now you need a better tool to surround text by certain characters? Alright, we also have nvim-surround. And this goes on for almost everything you ever needed.
And in the rare case that you can't find a plugin for what you need: Write it yourself! It's very easy to write plugins, as vim and neovim both have a lot of functions that help with writing those.

The steep learning curve

The biggest problem to vim is its steep learning curve. If you're someone who is already in a commercial setting and need to produce at a certain speed, learning vim will be pretty hard. As someone who is still in education I had the option of killing my coding speed for a few months, just so I could learn vim.

Alright, I'm convinced. Should I use vim or neovim?

That choice everybody should make for himself, but I use neovim.

What's the difference between vim and neovim?

The major difference is that neovim uses lua for its plugins, which vim is still on vimscript.
Most people prefer lua, as it's more intuitive to write and has loads of uses outside of writing neovim plugins, making lua a much more useful language than vimscript.

Which one has better plugins?

From personal experience, neovim has much better plugins, while not more.
The fact that they're written in lua makes them more performant than vimscript, which already is a big benefit. On top of that: The fact that learning lua is much more useful than vimscript means that more people are willing to spend time learning it, making neovim plugins feel much more refined.

Example comparison: fzf-vim vs. telescope

As someone that has been using fzf for most of the time, changing to telescope opened up so much more options. Telescope has integrated git diffs, commit histories, language server settings, and much more.
This is an example of how the commit history check looks like
Commit history of telescope

Conclusion

I think learning vim is something everyone that is still in education should do, independent of if you actually stick with it or not.
The great amount of configuration and useful keybindings makes using vim a great experience.

Top comments (0)