For a long time, I had been eager to learn text editing with vim, which a friend of mine calls the most powerful editor on earth. It is descriptions like these that raise my curiosity to find out more.
In this series, I am beginning my exploration of vi and vim. I will be sharing my experiences with you throughout the month of April. Anyway, let’s get started.
What is vim?
Vim is a widely used text editor on Unix-based platforms such as Linux. It is a direct descendant of the vi editor. To underscore its importance, you find it being central to the Unix culture , especially as it it is pitted against Emacs in the classic editor wars.
Brushing aside any controversies, Vim is a good editor that is found on almost every Linux distro.1 Vi is on every Linux base distribution, so learning to use it is an advantage.
“Vim” as its name implies, is supposed to be an ‘improved version of vi.’ For the most part, the keystrokes are the same.
So throughout this series, any reference I will make to vim equally applies to vi.
My motivation for Learning Vim
The answer has to do with not only the shell but the whole array of text-processing tools on Linux.
Vim’s text handling closely mirrors that of most shell tools such as
awk and of course the
ex utilities. So in addition to the fact that vi is already part of the base installation, I was motivated to learn more about vim and how it processed text.
For example, its search-and-replace commands work the same as in
sed where we have to use the addressing system to locate lines to work on, and issue the s command followed by a pair of slash characters to bind the string to search for and the replacement. E.g.
:%s/word/text/g will replace all occurrences of “word” with “text”.
In a future post, I will focus on these features in detail. This post is only an introductory one.
In short, there are three reasons for my motivation:
- Vi comes installed on almost every Linux distro. Learning it enables me to use even a remote platform on my VPS.
- The vi and vim keystrokes are integrated into most text utilities on Linux. Take for instance the movement keystrokes for most file managers such as
nnn, [Ranger] and
vifm. Even Window managers such as
dwmuse the popular
hhjklcombination for directional navigation.
- Finally, the keystrokes are heavily inspired by the underlying
ededitors: these keys have an advantage that they are used not only in other text utilities such as sed and awk, but are heavily steeped in the regular expression syntax itself. So using vim makes it intuitive to work with regexes.
And my attitude towards Emacs?
I am still using Emacs as my primary editor. I am not yet convinced that I need to fully participate in the editor wars. I find vim attractive, especially when I am working full-time on the console.
Emacs is like a mini-desktop that houses a number of applications that do different tasks at a time. With Vim, I use it when I am doing heavy text-processing.
Anyway, I am still playing around with vim. Perhaps my answer would have changed by the end of April, who knows. For the meantime, I find both editors great in what they do.
In the next instalment, I will start looking at the Vim Interface.
Not exactly true though. As Vim is
improved, you can only get vi not vim—but they are the same anyway.