Alright, so you might think that there are better ways to spend your Easter break than sitting all of your evenings customizing Neovim with no prior knowledge. You’re probably right. Sceptics may also say that I’ve reproduced VSCode instead of simply using it. They are also probably right. Or are they? 🤔
First of all, why learn Vim?
I am a big lover of keyboard and a great hater of a mouse or touchpad. The major reason for those extreme emotions is mainly caused by my (maybe superstitious) need to work as effective as possible. I feel like moving your hand from the keyboard to the mouse every time you want to move the cursor a few words back or forth, to create a new file, split the window or whatever, is a major waste of time. The problem with VSCode or any other graphical editor is that the necessity to use a mouse is encoded in the design of those applications. I tried using this Vim extension for VSCode, but it felt clunky and I couldn’t get used to it (the same goes for Vim browser extensions, but that’s a different story).
My frustration with GUI IDEs had grown for some time. I used Vim only for some small, fast changes, but I did know only a couple of hotkeys, so I didn’t use it in any serious coding sessions. I had been scared of learning Vim for a long time, but one day I decided to just use it and learn it on the fly. And that was a hecking good idea.
How did I learn Vim?
I think that vimtutor was a major drawback for me in learning Vim. That kind of learning feels artificial and I didn’t feel I got any value after completing it. My method was more organic in a sense. I’ve found some nice site with a nicely formatted cheat sheet of Vim shortcuts, printed it and hung it over my computer screen and just used Vim all the time. If I wanted to perform some action that I thought can be done neatly using some keyboard shortcut, I just scanned the list searching for an appropriate hotkey. I think that this approach is great. I’ve quickly memorized the shortcuts that were frequently needed and then it was quite easy to get used to some other, not so often, but equally helpful commands.
If you’ve also thought about trying Vim but felt like the entry-level is too high, then I seriously recommend trying this approach. If you restrain yourself to use it then I’m pretty sure that after a few days you’re gonna love Vim and appreciate it even more. Now, I’m not an expert, but still, I feel that with the basic knowledge I can do magic that was impossible for me in VSCode or any other GUI editor I used.
Neovim takes it to another level
I must admit, bare Vim with only the basic options it offers is still inferior to a GUI editor like VSCode (but I know some people that disagree). I like the idea of a file-searching engine, language server, session and project management, drop-down windows, file tree and many other features. Fortunately, those concepts are very well suited to a text-based editor like Vim. They’re just not there out of the box. This is where Neovim comes to play.
It’s important to note, that I’m no expert. Some Vim veterans may argue that Neovim is redundant bloatware and they may have some point. However, I feel that Neovim have some significant advantages over Vim:
- It’s developed by many contributors, whereas Vim is in hands of one person (it’s not entirely true, but just look at the commit history for both of those editors, it speaks for itself)
- Neovim is an implementation of Vim focused on performance and customizability and you can feel it,
- Customization can be done entirely in Lua, which feels like a great alternative for Vimscript (which is ugly IMHO),
- Neovim is great out of the box.
The only place where Neovim loses with Vim is remote access – there’s only Vim available on a remote server in most cases, but that’s a minor disadvantage in my case.
Searching for some cool plugins and tweaking them was a very cheerful time and I run into almost no problems during the whole process. And, to be honest, 20 hours for creating a virtually full IDE from scratch customized entirely for your personal needs does not seem that much time at all. Lua is an easy and pretty language for configuration code, I think I’ve learnt it pretty well just by reading plugins’ code. I’ve also followed this awesome tutorial. It is great, modular and easy to follow.
Sounds great, but I don’t have time for this
Bullshit. Seriously, you probably have time to watch some junk content on YouTube or whatever you like to waste your time on (I do it too, but still, it’s most often a waste of time, one can rest better), but don’t have time to work a little bit longer for a couple of days? Just try it out, learning Vim is not as scary as it may look at the first glance. After you learn to use the shortcuts for some time you can move to Neovim and try configuring it. And if you feel like it’s too much of a bother for you, then maybe try LunarVim or Neovide, which are some prepared Neovim configurations. I haven’t use them, but they look sensible. I still recommend taking your time to configure it yourself though. You’re gonna have full control over your configuration and after some practice, it’s going to be ridiculously simple to tweak it further. If you want to look at my configuration, then head to my git page.
Plan of action – switching to Neovim as your primary editor
- Try learning Vim shortcuts first. Don’t use any custom installation, just bare vim with a sensible .vimrc, like this one:
"sets line numbering and relative line numbering set number relativenumber set shiftwidth=4 set tabstop=4 "expands tabs to spaces set set expandtab "highlight current line set cursorline "ignore case in searching set ignorecase "if mixed case in search then don't ignore it set smartcase "scrolling begins at 5th line from top or bottom set scrolloff=5 "sets syntax highlighting on syntax on encoding=utf-8 "Saves the position of screen at exit autocmd BufWinLeave *.* mkview "Restores screen last position autocmd BufWinEnter *.* silent loadview
- Have the cheat sheet close. Try using hjkl instead of arrows. Don’t use your mouse. Learn how to search and replace text. Abuse w, e, b. Use <number><action> to perform an action number of times, for example, 5j moves the cursor 5 lines down. Use every visual mode. Learn how to copy and paste.
- Move to Neovim. Install packer, try configuring it. Install some basic plugins. I recommend following this tutorial by crhis@machine.
What’s your view on Vim or Neovim? Did you try it and still prefer a graphical editor? Do you have a strong opinion that Emacs is superior to Vim? If you have any thoughts, don’t hesitate and comment under this post. I’ll be more than happy to hear your opinion.