前言:The best way to learn Emacs is incrementally
- 从source insight走到Vim之后,用过VIM的Ctag,cscope时候也是一种选择。然后,对比source insight 对类定义和函数调用的各种引用,感觉vim还是有一定差距。也许,尝试Emacs是最终的选择,这也是笔者尝试重新开始的重要原因,一直觉得emacs很神奇,所以,期待这次努力,能够达到一定境界,能够逐步彻底淘汰掉VIM和Source insight.希望完成这个系列的时候,也是和大家一起能够基本掌握emacs的时候。【】请实践黑色括号扩起来的部分
- 本文主要讨论emacs 的非windows版本、终端模式
1 vim 的一些局限性:
比如Ctag的使用,首先要手动生成,然后,如果遇到有重复的定义,往往只能给你其中一个定义。各个结构,类的定义之间的切换比较困难。
比如Scope的使用,往往查找一个函数的调用,会首先给出一个很长很长的list列表,在里面逐个去查询调用的地方,比起source insight还是差太多了。
2 emacs 的第一步如何使用帮助
2.1 emacs 的进入和帮助菜单主页最基本操作:
如下命令会帮助你进入命令行模式
emacs -nw
版本24的emacs 会进入如下菜单
Welcome to GNU Emacs, one component of the GNU/Linux operating system.
Get help <f1>
Emacs manual <f1> r Browse manuals <f1> i
Emacs tutorial <f1> t Undo changes C-x u
Buy manuals <f1> RET Exit Emacs C-x C-c
Activate menubar M-`
(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.
If you have no Meta key, you may instead type ESC followed by the character.)
Useful tasks:
Visit New File Open Home Directory
Customize Startup Open *scratch* buffer
GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7)
of 2014-03-08 on lamiak, modified by Debian
Copyright (C) 2013 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY; type C-h C-w for full details.
Emacs is Free Software--Free as in Freedom--so you can redistribute copies
of Emacs and modify it; type C-h C-c to see the conditions.
Type C-h C-o for information on getting the latest version.
2.1.1 两个最最基本快键定义
这里强调了两个主要的快键键值:`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key.2.1.2 如何使用帮助菜单主页
type C-h C-w for full details
【C-h】会进入帮助主菜单
2.1.3 如何退出emacs
Exit Emacs 【C-x C-c】
上面这个“C-x C-c” 是什么意思?
表示:
1 先按住【Ctrl】 再 加【x】
2 先按住【Ctrl】 再 加【c】
做完步骤1,2 之后,会退出emacs
2.2 emacs 帮助菜单主页的选项
2.2.1 菜单栏
File Edit Options Buffers Tools Help
2.2.2 编辑区和对应的使用说明
2.2.2.1 Get help
Get help <f1>
Emacs manual <f1> r Browse manuals <f1> i
Emacs tutorial <f1> t Undo changes C-x u
Buy manuals <f1> RET Exit Emacs C-x C-c
Activate menubar M-`
【f1> r]】 表示先按F1 再按r
【M-`】表示先按【ALT】在按【`】,会进入菜单条选择菜单,这时候emacs会在右边新开一个窗口,并把菜单里面所有用的一些可能的键值都列表出来。
下面这个是菜单条
File Edit Options Buffers Tools Minibuf Help
读者可以逐个实验,这些命令其实和直接用鼠标在菜单上操作是一致。
Press PageUp key to reach this buffer from the minibuffer.
|Alternatively, you can use Up/Down keys (or your History keys) to change
Get help <f1> |the item in the minibuffer, and press RET when you are done, or press the
Emacs manual <f1> r Browse manuals <f1> i |marked letters to pick up your choice. Type C-g or ESC ESC ESC to cancel.
Emacs tutorial <f1> t Undo changes C-x u |In this buffer, type RET to select the completion near point.
Buy manuals <f1> RET Exit Emacs C-x C-c |
Activate menubar M-` |Possible completions are:
(`C-' means use the CTRL key. `M-' means use the Meta (or Alt) key. |b==>Buffers e==>Edit f==>File
If you have no Meta key, you may instead type ESC followed by the character.) |h==>Help o==>Options t==>Tools
上图,比如“ f==>File”
这个项目就是开始我们看到的主菜单上面的菜单条上显示的【file】项目
【案】右侧的pop windows 的退出可以用 【C-g】【ESC ESC】的方式,这两种退出方式也是结束pop out menu的主要快键方式。
正如 emacs手册所说,你只要去实践,你就会习惯输入的方式,这就像游泳,你只要会,你就不会忘记,所以,其实没有必要去记忆,只需要去实践就好了。
2.2.3 底部的mode line的解释
-UUU:%%--F1 *GNU Emacs* All L7 (Fundamental) ------------------------
2.2.3.1 在mode line中第1个字符
2.2.3.1 在mode line中第2个字符
%% 只读,未更改
-- 可写,未更改
** 可写,已更改
%* 只读,已更改
[-] 表示路径
2.2.3.1 在mode line中第3个字符
2.2.3.1 在mode line中第4个字符
2.2.3.1 在mode line中第5个字符
【小结】本节主要讨论了emacs首次进入时候的界面讯息,并强调了界面首页的基本操作命令。
参考:
1 从零开始——Emacs 安装配置使用教程 2015
http://www.jianshu.com/p/b4cf683c25f3
2 学习Emacs系列教程
http://www.cnblogs.com/robertzml/archive/2009/09/10/1564108.html
3 O'Relly Learning GNU Emacs, 3rd Edition
4 emacswiki
本文原创:
QQ; 28044280
微信公众号:NewTechLife
Email: huang.makin@gmail.com