Let me also talk about Emacs (1) - We both learn Emacs and Vi

Abstract: The "Soul of Emacs", a friend of the phantom god, is being serialized, and people in the group are coaxing to cheer him on. As a user who has repeatedly failed to learn Emacs, this field is still worthy of praise. At least I bought the HHKB keyboard. . .

The "Soul of Emacs", a friend of the phantom god, is being serialized, and people in the group are coaxing to cheer him on.
As a user who has repeatedly failed to learn Emacs, this field is still worthy of praise. At least I bought the HHKB keyboard. . .

Let's start with my keyboard - modal and non-mode
The following is a partial diagram of my HHKB keyboard:
hhkb

is different from other conventional keyboards, the position of the Control key of my keyboard is the position of the caps lock key of the conventional layout. Why is it laid out like this?

Let's take a look at the most common emacs shortcut keys introduced by the magic god in emacs human world usage:

Cf next character
Cb previous character
Cp previous line
Cn next line
Mf next word
Mb previous word
Ca start of line
Ce end of line
Cv page down
Mv page up
M-< to the beginning of the file
M-> to the end of the file

Cx Cf "find" the file, that is, open/create a new file in the buffer
Cx Cs save the file
Cx Cw use another file name to save as
Close current buffer file and open new file for file Cx Cv
Cx i Insert a file at the current cursor
Cx b Create/switch buffer
Cx Cb Display the buffer list
Cx k Close the current buffer
Cz Suspend emacs
Cx Cc Close emacs

Where, C means Ctrl key, M means Alt key, Cf means press Hold Ctrl and then press f,
Cx Cs means press Ctrl+x first, then Ctrl+s,
Cx b means press Ctrl+x first, then press b.
The common use of the Ctrl key is evident.
This leads to a famous paragraph: because the Ctrl key is used a lot in emacs, and the Ctrl key of the ordinary keyboard is located under the little finger tube but the more laborious key position, emacs will cause the left little finger to be easily damaged. In order to improve efficiency, changing the keyboard layout is one of the most commonly used methods. If you don't believe me, try it, is it easier to press Caps lock than to press Ctrl, just move your finger a little bit.
In addition, emacs also has a lot of demand for Alt or Esc, and these two keys are also the jurisdiction of the little finger.

Mode and Modeless
Why does emacs use the Ctrl and Alt key combinations so heavily? The reason is simple, emacs is a modeless editor. Relatively speaking, vi is a mode editor, divided into command mode and editing mode. In the command mode, j is to move down one line, k is to move up one line, h is to move to the left, l is to move to the right, and the hand can move quickly when the hand does not move on the basic key position.
Since most of the keys are treated as commands in command mode, what should I do if I enter the characters represented by these keys? This requires switching to the editing mode through the i command, o command, etc. In the editing mode, characters can be input normally. However, in edit mode, most commands are no longer available. When using a command, you also need to enter Esc to switch back to command mode.

As a result, the religious war between emacs and vi has been fought for decades on the battlefield with and without mode.

emacs lisp and vimscript
are the two heroes of the editor crusade. In addition to the basic functions, emacs and vim have their own extension languages: emacs is emacs lisp, and vim is vimscript.
Both are not so modern languages. The emacs lisp is not as powerful and complex as the common lisp, but the fans are like clouds, and new fans are constantly joining in. There are almost no fans of vimscript, those who use perl to write vim extensions, and those who use python to write vim extensions. . .

In the two divisions of the war of religions, lisp has the advantage, and emacs' platform has the advantage. In the mode competition, the advantage of vi's shortcut keys makes it relatively more users.

evil - emacs vi mode on emacs
So , are emacs and vim really going on a religious war inexorably? For emacs users, this has never been the case. Emacs users take emacs' extensibility as a weapon and develop plugins that simulate vi-mode solutions, evil is one of the most popular ones.
Another effective output method for vi users is to use the leader key to combine commands with the leader key.

There are many plug-ins for spacemacs
emacs, and the configuration is also complicated, so the best way to learn to use emacs is to learn from the configuration schemes that have been prepared by experts. At present, the more popular solution is spacemacs.
spacemacs uses evil by default to simulate the vi mode, and uses the space key as the leader key.

The following is a screenshot of the interface of spacemacs:
spacemacs

In the default mode, enter the space bar, and the command represented by the next key will pop up, for example: space, then f, the displayed interface is as follows:

spacemacs f

The installation of spacemacs is very simple, there is only one command:

git clone https://github .com/syl20bnr/spacemacs ~/.emacs.d
At this point, our emacs learning journey officially begins. We not only learn emacs, but also learn vi mode and leader key. At the same time, we use spacemacs, which has already configured many powerful plugins for us by default, which is more convenient than the ordinary version.

The only downside is that we may have learned more knowledge than the phantom gods in the human world. After all, vi is an editor with a steeper learning curve. But just stick with it and you'll find it worth it!

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326609186&siteId=291194637