Where should I even start with this post? I do not want to explain and retell the whole history of Vi, Vim, and Neovim, or the war between that entire ecosystem and Emacs. I want to approach this more personally and talk about my own experience with these amazing editors: how it all started and how I got to the point where I cannot imagine working with text any other way. Occasionally using Office or some other editing tools now ends with my text being sprinkled with :wa, because it has become such a habit that it pushed keyboard shortcuts like Ctrl + s out of my head.
First contact with Vi Link to heading
I first heard about vi during my first year at university, when a professor decided to pull the classic joke: during a lab class, he first told us to edit a file with it, and then to exit the program without giving us any instructions. After 15 minutes he took pity on those who did not know how to exit the program and suggested using nano as a badge of shame and inexperience. I was one of those shamed people.
That makes it even harder for me to believe now that I use Neovim even for my notes. Although I have to admit that it was not an easy journey at the beginning. One of my problems is also that I never fully learned touch typing. I am not the slowest writer when I write something off the top of my head, but copying text is a different story.
Why did I start? Link to heading
For a simple reason: later jobs and roles required me more and more often to quickly modify files on servers, luckily test servers, not production ones. nano turned out to be very limited in those use cases. Then came things like developer virtual machines for building huge codebases. It was faster to start working on code directly on those remote machines than to set up the whole environment locally and then synchronize the code. Another argument was the recent Neovim boom and its various distributions, fueled in my internet bubble by people like TJ DeVries, Primeagen, or Typecraft. All of that pushed me toward Vi and Vim motions. So now let me take you through how to get started.
Jumping in at the deep end or just dipping your toes Link to heading
How you get into the topic is your choice. I will only show you a few ways to do it. I chose the jump, but it came with a small dose of frustration and fatigue, because at the very beginning many simple actions took me absurdly long. The mere awareness that you can open your favorite editor at any moment and write that code there just like that, instead of struggling even with selecting a few lines and copying them, is very discouraging. And then comes the moment when something clicks in your head and you no longer want to go back.
It was intense, but it forced me to quickly build muscle memory for at least the basic shortcuts. So how did I do it? I installed Neovim and picked one of the popular distributions, LazyVim, to have a starting point. I know some people consider using a distribution at the beginning to be sacrilege, but for me it was very convenient. The only thing worth remembering is to distinguish basic Vim usage from shortcuts provided by the distribution. The best way to do that, and to remember the basic motions, is to print a cheat sheet and stick it under your monitor. It worked like a charm for me. Example cheat sheets:
- https://vim.rtorr.com/
- https://www.vimgym.dev/blog/vim-motions-cheat-sheet-beginners
- https://rumorscity.com/2014/08/16/5-best-vim-cheat-sheet/ (I personally used the second one from that link because it is visually approachable)
And what about those who would rather start slowly? If you use VS Code every day, install one of these extensions: Vim or VSCode Neovim. I would suggest the first one, because you do not need what Neovim offers here. You only want to control VS Code with Vim motions. This lets you get used to shortcuts and key combinations in a controlled way, inside a familiar environment.
What else can you do to learn it? Link to heading
There is also something called vimtutor. It is a program built into Vim and Neovim that teaches the basics of using the editor. It is definitely worth running and going through a few times for practice. How do you start it? If you have Vim installed, use the vimtutor command. If you have Neovim, use nvim +Tutor.
The most important options to set at the very beginning Link to heading
There are a few options I always set, no matter where I open Neovim:
local opt = vim.opt
opt.number = true
opt.relativenumber = true
opt.colorcolumn = "120"
opt.scrolloff = 20
opt.spelllang = { "en", "pl" }
opt.wrap = true
Let’s go through these options one by one and see what they do:
number- enables line numbers, which is very helpful because many operations can be performed by passing the number of lines or characters that should be affected. For example,5yjwill copy five lines in Vim, including the current one.relativenumber- changes line numbering to be relative to the active line, while the active line itself shows its actual number in the filecolorcolumn- adds a marker at the given column so you can visually see when your lines are getting too longscrolloff- keeps the given number of lines visible above and below the cursor while scrollingspelllang- sets the default languages for plugins that check spellingwrap- wraps long lines instead of hiding content beyond the edge of the screen
Try it yourself Link to heading
It is important to experience and try things yourself, because that is how we learn the most. This article deliberately does not hold your hand. It only shows the context of why I use this and how I think it is best to start. I hope discovering Neovim will be a lot of fun for you.
Combined with tmux, which you can read about in my previous article, you get an environment for writing, testing, and running code directly in the terminal.