前言,

上一节我们大致说明了emacs的开启主菜单的基本元素和基本操作,这一节,我们尝试运用emacs提供的教学浏览功能,对emacs做一个大致的理解。

emacs 内置的tutorial里面对各种基本操作都有了高亮的定义,而且,就像一个老剑客一样会逐步引导你慢慢开始使用emacs,所以,这份快速使用手册是非常有实践意义。

所以,我作为初学者会认真走一遍他的操作。


1 如何使用tutorial

a 在输入 【emarcs -nw】之后,输入【F1+t】进入emacs 教学浏览
b Tutorial 里面提到输入【h】后,将进入 1.2 How to use Info // 或者在shell里面直接输入"info"

1.1 导航-页面切换-在不同页面切换练习


emarcs 的buffer概念有点像一个你打开的文件这个概念。在一个buffer里面如果有当前一个frame无法显示,那么就会有页面切换的操作。


【C-v】【M-v】【C-l】

* SUMMARY
---------

The following commands are useful for viewing screenfuls:

        C-v     Move forward one screenful
        M-v     Move backward one screenful
        C-l     Clear screen and redisplay all the text,
                 moving the text around the cursor
                 to the center of the screen.
                 (That's CONTROL-L, not CONTROL-1.)



1.2 导航-光标的基本控制

Previous line, C-p
                                  :
                                  :
       Backward, C-b .... Current cursor position .... Forward, C-f
                                  :
                                  :
                            Next line, C-n

页面光标导航键拓展

Here is a summary of simple cursor-moving operations, including the
word and sentence moving commands:

        C-f     Move forward a character
        C-b     Move backward a character

        M-f     Move forward a word
        M-b     Move backward a word

        C-n     Move to next line
        C-p     Move to previous line

        C-a     Move to beginning of line
        C-e     Move to end of line

        M-a     Move back to beginning of sentence
        M-e     Move forward to end of sentence
        >> Try all of these commands now a few times for practice.These are the most often used commands.



【案】上述是emacs 帮助文档的总结,其中>>是给出的练习,边学边练习,个人感觉还是蛮有效果,基本上20分钟可以掌握光标的操作。

感觉还有2组很有用的光标操作

【M-}】【M->】 M(ALT) 键的操作要比【 C(Ctrl)】的大一些,其中

【M-}】表示跳到下一个段落

【M->】表示跳到最后一页,注意其中【}】【>】等字符因为处于键盘的复用键值,需要按住【shift】所以实际操作如:【M-}】= 【M - ALT】+ 【SHIFT】+【}】

emacs 不推荐光标键的理由

You can also move the cursor with the arrow keys, if your terminal has
arrow keys.  We recommend learning C-b, C-f, C-n and C-p for three
reasons.  First, they work on all kinds of terminals.  Second, once
you gain practice at using Emacs, you will find that typing these Control
characters is faster than typing the arrow keys (because you do not
have to move your hands away from touch-typing position).  Third, once
you form the habit of using these Control character commands, you can
easily learn to use other advanced cursor motion commands as well.




2 重复执行命令前缀

之所以说重复执行命令前缀,因【C-u】表示后面要跟一个重复数,这个数是下一个命令要执行的次数。

【C-u】+ 【8】+【C-v】表示要对【C-v】执行8次

当然,不是所有的命令都是严格这样执行,比如,【C-u 8 C-v】就不是重复翻页8次(原本C-v是翻页到下一页的意思),而是变成了8行,

【案】emacs类似的不严谨逻辑的地方还有很多,比如 【M-{】却没有【C-{】


3 如何取消输入一半的命令 【C-g】

我们一般会习惯用【ESC】在emacs里面ESC可以是组合键的开始,

【C-g】用来停止哪些没有反应或者输入到一半你想退出的键输入。


4 默认关闭的功能键组合如何控制 DISABLED COMMANDS

emacs里面有很多默认关闭的组合键,

【C-x C-n】: 

例如: 这个是设置当前列为目标列。这是什么意思呢,本来我们按C-n 和C-p 时,光标会往下或往上移一行,而列的位置就是当前光标列的位置,除非下一行列没那么多(就是字符没那么多),光标会到距当前列最近的列。而我们可以用这个组合键重新设一个目标列,这样在按C-n 和C-p 时,光标会跑到我们设的目标列上。

Set the current horizontal position as a goal for C-n and C-p.
If Emacs stops responding to your commands, you can stop it safely by            |   Those commands will move to this position in the line moved to
typing C-g.  You can use C-g to stop a command which is taking too long to execu\|   rather than trying to k

如果你不小心输入了这些键,对第一次使用,会弹出来一个对话框


You have typed C-x C-n, invoking disabled command set-goal-column.
                                                                                 |It is disabled because new users often find it confusing.
* IF EMACS STOPS RESPONDING                                                      |Here's the first part of its description:
---------------------------                                                      |
                                                                                 |   Set the current horizontal position as a goal for C-n and C-p.
If Emacs stops responding to your commands, you can stop it safely by            |   Those commands will move to this position in the line moved to
typing C-g.  You can use C-g to stop a command which is taking too long to execu\|   rather than trying to keep the same horizontal position.
te.                                                                              |   With a non-nil argument ARG, clears out the goal column
                                                                                 |   so that C-n and C-p resume vertical motion.
You can also use C-g to discard a numeric argument or the beginning of           |   The goal column is stored in the variable `goal-column'.
a command that you do not want to finish.                                        |
                                                                                 |Do you want to use this command anyway?
>> Type C-u 100 to make a numeric argument of 100, then type C-g.                |
   Now type C-f.  It should move just one character, because you                 |You can now type
   canceled the argument with C-g.                                               |y   to try it and enable it (no questions if you use it again).
                                                                                 |n   to cancel--don't try the command, and it remains disabled.
If you have typed an <ESC> by mistake, you can get rid of it with a C-g.         |SPC to try the command just this once, but leave it disabled.
                                                                                 |!   to try it, and enable all disabled commands for this session only.



根据这个设定建议,

你可以选择y使能,n 取消, SPC 尝试执行一次, !这个比较搞,会使能所有的隐藏组合键。


【C-x C-l】也是同样的隐藏组合键,用了切换到小写: 




5 Windows 的基本操作