Not Difficult, Only Different
The simple need to move the cursor around in a text editor becomes not-so-simple when it must be done with the keyboard instead of a pointing device such as a mouse.
Moving around in the Big Three text editors
The simple need to move the cursor around in a text editor becomes not-so-simple when it must be done with the keyboard instead of a pointing device such as a mouse.
A newcomer to any of the Big Three open-source text editors, Vim, Emacs or Nano, will find all of them let users do great things but differ in how to do them. The burden of learning new techniques can make good tools feel unduly difficult at first. This feeling goes away after some practice settles the techniques comfortably under the user’s fingers.
I am writing this post on a Tuesday using the Emacs editor, three days after I began by reading its documentation found online. It was a mistake to start that way. The online help feels like wading waist deep through congealing gelatine.
I began to enjoy Emacs more by simply opening a file and typing some text. Soon enough I had questions. Yet before too long, I was finding answers.
Must say here that much of the Emacs documentation gives off a For-Professional-Use-Only air that feels suffocating to a newcomer. Some doors need knocking on more than once before they open, and repeated reading taught me more places to look for helpful information.
The same grumble about documentation can be said for Vim also and, to a lesser extent, for Nano.
Perhaps the first thing to learn for any of these editors is how to move the cursor. All three of the editors provide similar operations. They differ in which keystrokes to use.
The table below describes selected cursor-movement keystrokes for each of the Big Three editors. Please keep a few things in mind as you view the list.
Vim makes you switch back and forth between text-insert mode and cursor-movement mode. This means you have to press the ESC key to get out of typing mode. The cursor movements then need just a single keypress. Finally, one must press a special key to re-enter text-insert mode.
By contrast, Nano and Emacs provide for cursor movement while remaining always in typing mode. They do this by combining several keystrokes together for the movement commands.
The cursor-movement key combinations for Emacs and Nano are written here as C-x or as M-x, where x stands for a cursor-movement key. C- means to hold down the Control (ctrl) key while also typing the cursor-movement key. Similarly, M- means to combine the cursor-movement key with a so-called Meta key. What key is that?
It is likely to be the ‘alt’ key for many computers and operating systems. On a Raspberry Pi it might be the combination of Shift and alt. Figuring this out for one’s particular device can contribute toward making these editors feel awkward at first.
Motion | Keystroke |
---|---|
Next Character |
All: right-arrow Vim: l Nano: C-f Emacs: C-f |
Previous Character |
All: left-arrow Vim: h Nano: C-b Emacs: C-b |
Next Line |
All: down-arrow Vim: j Nano: C-n Emacs: C-n |
Previous Line |
All: up-arrow Vim: k Nano: C-p Emacs: C-p |
Previous Line |
All: up-arrow Vim: k Nano: C-p Emacs: C-p |
Next Word |
Vim: w Nano: C-space Emacs: M-f |
Previous Word |
Vim: b Nano: M-space Emacs: M-b |
Start of Line |
Vim: 0 (zero) or <home> Nano: C-a Emacs: C-a |
End of Line |
Vim: $ or <end> Nano: C-e Emacs: C-e |
These are just a few examples. Many more await the determined learner. Each editor implements cursor movements (and many other things) differently to the others. Yet for all three, it may surprise a newcomer how quickly the keyboard becomes a faster means to position the cursor compared to the mouse, for the simple reason that the hands can remain on the keyboard.
My point here is a humble one. The grumbles one finds online about difficulty with this-or-that text editor come mainly from people who have not learned much about it — yet. Folks tend to settle down and go quiet as they gain facility with the tool.
On the other hand, some veteran users can become outspokenly opinionated in favor of a text editor they have labored at length to master. This phenomenon was once known as editor wars
. It is the subject of a recent article on a sibling site, Code Diarist: The Editor Wars