改变Emacs下的注释代码方式以支持当前行(未选中情况下)的注释/反注释
Emacs下支持多行代码的注释/反注释,命令是comment-or-uncomment-region。
我喜欢把它绑定在快捷键C-c C-/上,如下:
(defun my-comment-or-uncomment-region (beg end &optional arg) (interactive (if (use-region-p) (list (region-beginning) (region-end) nil) (list (line-beginning-position) (line-beginning-position 2)))) (comment-or-uncomment-region beg end arg))(global-set-key [remap comment-or-uncomment-region] 'my-comment-or-uncomment-region)
(1)它不会像Eclipse那样,在选中多行注释的时候,把其中的空行也加上注释
(2)Eclipse的注释一律加在一行顶头的位置,而Emacs会加在相应indent对齐的位置。
当然,具体的行为方式在Emacs中肯定是可以调整的,对我来说现在Emacs的方式已经可以满足我的需要了。
参考url:http://www.emacswiki.org/emacs/WholeLineOrRegion
/********************************************************************
* 不落魄的书生的记事簿[blog.csdn.net/songyuanyao]