Long time no see, but I'm back. I had a lot of things to deal with, that prevented me from writing here in the frequency I'd like. But without further ado, let's talk about the theme: Vim/Neovim and the VSCode.
There is a certain bad fame that surrounds Vim or its more modern variant, Neovim. For being an old program that runs at the terminal, one who sees it and compares with the most beloved editor of the moment - VS Code - soon thinks: "How can someone with some self-love would want to deal with this stuff? It is ugly and hard to use, and when I tried to quit it I failed!"
On the other hand, those who use it does not want to switch to other IDEs1. I wonder why. They must have a reason, because I can't see how such bad piece of software could last so long. Before dealing about the differences between the editors, let's first understand what is Vim.
What is Vim?
Vim is just a text editor that runs directly on the terminal or with a visual interface, based on modes and commands. To understand it better, let's get to know a little about its history.
Vi - Visual editor
Vi is a text editor created by Bill Joy in 1976, for a Unix derivative system, called BSD 2. This BSD is the basis for the system used in Macs nowadays.
Vi was based on another editor called Ex, very useful for editing configuration files with the limitations of the computers of the time. It works with commands inserted in a line at the bottom of the screen. When typing visual
or your abbreviation vi
in the editor, a "visual mode" opens and enables an easier way for editing: with a cursor on the screen, similar to what we are familiar with. The name "vi" comes from the command used to enter the Ex visual mode.
Vi differs from others because it is a modal editor, i.e., keys can contain different functions depending on the mode. I will talk about how these modes work later.
Vim - Vim Improved
Vim is an editor created by Moolenaar, based on the Stevie editor, which was a vi version for the Atari ST.
It is very similar to the original Vi, but with many additions, making it more modern and easier to use. You can configure mouse usage and install extensions, for example.
Neovim
Although Vim came to be a good enough editor, all updates are approved by Bram Moolenaar himself to be applied in the new versions. As the open source world requires speed and less centralization, and in addition, the Vim code has already become quite hard to maintain and extend, Neovim was born: yet another VIM clone, focused on extensibility and usability. Part of this new code is written in Lua3.
Modes
As promised, now I will explain what the modes are and how they work.
At some point in time, you used some app that has its UI organized in steps. Modes work similarly: each one has its way of interacting with the content. It makes you have a specific focus when editing.
Affinity Designer is an example of an application that uses modes nowadays. You have a drawing mode, a painting mode and another one for export assets. In this app, modes are nicely called "personas".
In the same way, Vim/Neovim treats the text editing. Namely, the modes are:
-
Normal: Doesn't allow inclusion of text, but quick changes to it, such as replacing letters, deleting content, copy or paste lines. It is the mode the editor opens by default. It is enabled with the
Esc
button. -
Visual: Allows the selection of text. Activated by shortcut
v
-
Insertion: This mode allows you to write text. Enabled with the
i
button. -
Command: Allows the user to write commands in the status bar, such as saving the file or split the screen. Enabled by the
:
. -
Replacement: Works like the
insert
button on the keyboard. When typing, characters are replaced. Activated withR
.
In the end, what makes Vim look more complicated is the presence of the modes. They are responsible for the phrase "I can't quit Vim", because to quit it, you first need to enter the command mode and enter the keyword or abbreviation.
In practice, this means typing :q
and hitting ENTER, being :
to access command mode and "q" for "quit", to exit the program.
What seems very difficult at first, becomes natural with time, believe me. I can't count how many times I caught myself doing the command to save :w
in other text editors, hahah...
Comparing with VS Code
Don't get me wrong, I love VS Code. It is really an awesome code editor, and be aware that I'm not a Microsoft fanboy. Despite using Electron as a base, VS Code got a certain "lightness" that other competing editors using the same technology failed: Atom is an example of this.
VS Code: Electron in all its glory
The problem is, as some may know, Electron is not a native application, so it will never be fast like one. I had various crashes using it, and that's really boring. And when you know this is due to Electron, it is even more annoying, because the solution is to upgrade your system, which is not cheap at all. Add extensions and background processes to it, the things get even more troublesome.
Neovim: When it's well configured, it doesn't look like a terminal program
Another thing that a terminal editor can make and VS Code can't: enable direct editing on the command line. When you access a server via SSH, it will not be possible to run VS Code directly there. So even if you don't use Vim on a daily basis, know its basics will help you a lot in these occasions, as it will probably be available on the system by default.
Wrap up
As I don't depend exclusively on VS Code to do my job, I decided to switch to Neovim, which is a native and lightweight application. Besides that, you learn a new way to edit code that is quite efficient and amusing when you master it. You can even configure it in such a way that it resembles a lot VS Code, including support for equivalent extensions.
This is what I will address in the next articles. See you!
Links
If this article helped you in some way, consider donating. This will help me to create more content like this!
-
IDE: Integrated Development Environment, IDE is a developper-friendly text editor, with tools to easy code creation. ↩
-
BSD: Berkeley Software Distribution, was a Operating System based on UNIX, with a very permissive open source license. Today it is a term to include all OS based on in, like OpenBSD, FreeBSD and Darwin, that is used in MacOs. ↩
-
Lua: It is a programming language originally designed for extending applications and systems, created by the Brazilians Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes, members of the Computer Graphics Technology Group (Tecgraf) at the Pontifical Catholic University of Rio de Janeiro, in Brazil. Today it is a multi-paradigm language used in many areas. ↩
Top comments (4)
Neovim 5.0 is amazing. Blazing fast and the lua support will bring lots of people to the community.
Why is the neovim link sending me to vivaldy browsers website?
I think you may have made a copy paste error
My bad. It is fixed now, hahahah...
Try Lite-XL alternate to VSCODE