Emacs杂项

expand-region

 
  1. (add-to-list 'load-path "expand-region.el所在的目录")  
  2. (require 'expand-region)  
  3. (global-set-key (kbd "C-=") 'er/expand-region)  

 

  1. 智能扩展标记:

    Expand region increases the selected region by semantic units. Just keep pressing the key until it selects what you want.

    An example:

    (setq alphabet-start "abc def")
    With the cursor at the c, it starts by marking the entire word abc, then expand to the contents of the quotes abc def, then to the entire quote "abc def",
    then to the contents of the sexp setq alphabet-start "abc def" and finally to the entire sexp.

    mark-multiple

    (add-to-list 'load-path "mark-multiple.el所在目录")  
    (require 'mark-more-like-this)  
    (global-set-key (kbd "C-<") 'mark-previous-like-this)  
    (global-set-key (kbd "C->") 'mark-next-like-this)  
    (global-set-key (kbd "C-M-m") 'mark-more-like-this) ; like the other two, but takes an argument (negative is previous)  
    (global-set-key (kbd "C-*") 'mark-all-like-this)  
    选中region后,按下C-> 会同时选择下一个内容相同的region,对一个region的操作即对所有选中region的操作。
     
    PS:此mode中还有一个inline-string-rectangle mode,个人感觉用处不是很大,因为Emacs自带有cua-mode,已经比较好用了。

     

 

session

配合desktop可以保存我们上一次的工作状态。也就是重新打开Emacs的时候,会变成上次关闭的状态。当然也可以 分项目保存不同的session ,这样就和IDE保存工作区一样了。

undo-tree

Emacs的undo非常诡异,只有undo,没有redo。如果要redo,那只有undo undo。

不过这样的设计,让Emacs的撤销变得异常强大。Emacs可以帮你所有的修改记录都保存下来,我们可以肆意地修改、undo完修改,各种修改,我们都可以回到曾经的状态。这个是其他编辑器难以做到的。

undo-tree可以将所有的状态用树状结构绘制出来。然后我们轻松地可以找到我们需要的状态,甚至可以diff不同的状态。

我们按 C-x u 可以进入undo-tree-visualizer-mode, 然后 p 、 n 上下移动,在分支之前 b 、 f 左右切换, t 显示时间戳, d 打开diff,选定需要的状态后, q 退出。这是主要的操作,其它的自己摸索好了……

 

 

一些有趣的快捷键

  • C-M-h 标记一个函数定义
  • C-h C-a about-emacs
  • C-h C 查看当前文件的编码
  • C-u M-! date 插入当前时间
  • C-u M-= 计算整个缓冲区的行数、字数和单词数
  • C-x <RET> f utf-8 (set-buffer-file-coding-system),设置当前buffer的文件的编码
  • C-x C-+ and C-x C-- to increase or decrease the buffer text font size
  • C-x C-q 开关read-only-mode,在dired-mode中可以进入修改模式,可以批量修改文件名。
  • C-x C-t 交换两行。可以用来调整python中import
  • M-x sort-lines 排序选中行。
  • C-x C-v or M-x find-alternate-file 重新打开当前文件,在高亮后者插件出了bug可以用这个命令重新加载。
  • C-x z 重复上一条命令。可以一直按 z 不断执行,非常方便!
  • M-& 异步运行一个shell命令
  • M-: 运行一句lisp
  • M-@ mark-word,连续按连续mark单词。
  • M-g M-g linenum 跳到某行,同vim中的 [linenum]G
  • M-h 标记一段
  • M-x dig
  • M-x ifconfig
  • M-x ping
  • M-x telnet
  • M-z 删除到某个字符,同Vim的 df
  • C-u M-! date 插入当前时间
  • C-q C-i 插入tab
  • M-x list-colors-display 显示Emacs所有的颜色,方便我们来进行配色
posted @ 2016-06-07 17:34  是的哟  阅读(230)  评论(0)    收藏  举报