Skip to content

Instantly share code, notes, and snippets.

@secwang
Created December 31, 2014 02:38
Show Gist options
  • Save secwang/c70d61f019b9986a5b3c to your computer and use it in GitHub Desktop.
Save secwang/c70d61f019b9986a5b3c to your computer and use it in GitHub Desktop.
emacs usage

emacs

emacs 是一个简单的文本编辑器,不过它开始于 1976 年。一个软件的生命周期如果超过快 40 年的话,那么它一定是有可取之处的。


basic config

For OS X: Mac 用户就直接到下面去下载 binary package 就好。

http://emacsformacosx.com

一般来说,不推荐直接去编译 emacs ,因为非常慢。也不推荐在终端去使用 emacs , 一方面 terminal 在接受特定字符的输入的反应比较奇怪,比如 C+= ,或者 C+@ ,另外一方面 在终端里开 emacs 感觉会比较怪。

config use prelude

curl -L http://git.io/epre | sh

下载下来之后,需要对 prelude 加载的 module 文件稍微调整一下。

eg.

;; Emacs IRC client  
(require 'prelude-erc)  
(require 'prelude-ido) ;; Super charges Emacs completion for C-x C-f and more  
(require 'prelude-helm) ;; Interface for narrowing and search
(require 'prelude-helm-everywhere) ;; Enable Helm everywhere
(require 'prelude-company)
(require 'prelude-key-chord) ;; Binds useful features to key combinations
(require 'prelude-mediawiki)
;; (require 'prelude-evil)

最后一个 evil 没有尝试过,但是据说 bbatsov 本人是使用evil的。


tips

helm

helm 是 ido 的一个replacement,有一个非常霸气的介绍,A Package in a league of its own

使用helm记住两个快捷键就可以愉快的生活下去。

C-j 提供一个 tmp buffer 预览文件
C-o 切换 search 的 region

expand-region

用过 idea 的同学都会对那个神奇的expand select 印象深刻, emacs copy 了这个功能。

C-= expand-region-mode,C-=之后 = 绑定expand again , - 减少select的范围 ,0 回到原点。

key-chord

jk ace-jump 按单词的首字母查询,这个跳转是跨 buffer 的 ,也可以用于分屏后的切换。

JJ 跳回到原来的buffer。

Projectile

textmate 会默认把一个带有 .git 的文件当作是一个项目,Command-T 会自动的在这个文件夹下 按文件名寻找文件。

C-c p p change emacs location through. bookmark 文件,放在 .emacs.d 下里面的projectile-bookmarks.eld。

cat projectile-bookmarks.eld
("~/workspace/rui/site/" "~/.emacs.d/" "~/workspace/rui/service/" "~/temp/a/" "/Users/secwang/workspace/rui/service")

C-c p h 在文件夹下找对应的文件,相当于 command + T

C-c p r 在文件夹下repalce 指定的word,并且自带选择

brew install ag ack

C-c p s a 在文件夹下用 ack search

C-c p s s 在文件夹下用 ag search string

magit

magit 是 emacs 给 git 提供的一个前端。

比较好用的workflow有。

M-x magit-status
S 把目录下所有 unstage 的文件 stage,相当于 git add .
c c 提交commit ,相当于 git commit
c a amend commit ,相当于 git commit --amend
e 对本地的分支执行 git rebase -i , fixup 和 squesh 都可以用来合并commit

TODO stash

cider

C-x C-e 执行上一个括号内的内容 ,执行结果里面显示在 miniframe 里。 C-c C-r cider-eval-region 执行在 region 里面的文件,结果也是显示在 miniframe 里。

ispell

brew install aspell --with-lang=en

ispell 可以对整个 buffer 进行拼写检查。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment