Emacs Introduction
Table of Contents
安装指南
安装配置
Linux环境安装Emacs
sudo apt-get build-dep emacs24
sudo apt-get install ttf-ubuntu-font-family ttf-wqy-microhei
wget http://mirrors.ustc.edu.cn/gnu/emacs/emacs-24.5.tar.gz
tar -xzvf emacs-24.5.tar.gz
cd emacs-24.5
./autogen.sh
./configure
make && sudo make install
将如下代码写入~/.bashrc
,以便能支持中文输入:
alias emc='LC_CTYPE=zh_CN.UTF-8 emacs &'
使用我的配置文件:
git clone https://github.com/mickyching/emacs.d ~/.emacs.d git clone https://github.com/mickyching/elpa ~/.emacs.d/elpa
Mac环境安装Emacs
brew install emacs --with-cocoa
Windows环境安装Emacs
实用命令
C-h C-h # 查看帮助信息 C-h b # 查看所有已绑定按键
describe-coding-system # 查看当前编码状态 revert-buffer-with-coding-system # 更换编码解析文件 set-buffer-file-coding-system # 修改编码,会修改文件 align-regexp # 按照指定表达式对齐,用于代码排版 hexl-mode # 用于查看二进制文件 toggle-truncate-lines # 截断长行开关,开启则不显示超出部分 visual-line-mode # 虚拟换行模式,比折行显示更美观
实用插件
gtags
M-. # 查找定义/引用/文件 C-M-. # 查找定义,支持正则表达式 C-] # 查找引用 C-c M-g # ggtags-grep M-p/M-n # 上一处匹配/下一处匹配 M-</M-> # 第一处匹配/最后一处匹配 M-{/M-} # 上一文件/下一文件 M-= # 回到起始查询位置 C-c M-p/C-c M-n # 上一处记录/下一处记录 C-c M-h # 查询历史记录 M-* # 出栈
magit
C-x g # 查看状态 h/? # 查看帮助信息
在magit模式下,查看帮助信息如下所示:
Popup and dwim commands A Cherry-picking b Branching B Bisecting c Committing d Diffing D Change diffs e Ediff dwimming E Ediffing f Fetching F Pulling l Logging L Change logs m Merging M Remoting o Submodules P Pushing r Rebasing t Tagging T Notes V Reverting w Apply patches W Format patches X Resetting y Show Refs z Stashing ! Running Applying changes a Apply s Stage u Unstage v Reverse S Stage all U Unstage all k Discard g refresh current buffer TAB toggle section at point RET visit thing at point C-h m show all key bindings Common Commands C-c C-c Set defaults C-h i View popup manual C-t Toggle this section C-x C-s Save defaults ? Popup help prefix C-g Abort
对于每个命令的具体用法,请参考如下相关资料: