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.html

    An example:python


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

    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保存工做区同样了。git

undo-tree

Emacs的undo很是诡异,只有undo,没有redo。若是要redo,那只有undo undo。github

不过这样的设计,让Emacs的撤销变得异常强大。Emacs能够帮你全部的修改记录都保存下来,咱们能够肆意地修改、undo完修改,各类修改,咱们均可以回到曾经的状态。这个是其余编辑器难以作到的。shell

undo-tree能够将全部的状态用树状结构绘制出来。而后咱们轻松地能够找到咱们须要的状态,甚至能够diff不一样的状态。vim

咱们按 C-x u 能够进入undo-tree-visualizer-mode, 而后 p 、 n 上下移动,在分支以前 b 、 f 左右切换, t 显示时间戳, d 打开diff,选定须要的状态后, q 退出。这是主要的操做,其它的本身摸索好了……session

 

 

一些有趣的快捷键

  • 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全部的颜色,方便咱们来进行配色
相关文章
相关标签/搜索