现在的位置: 首页 > 综合 > 正文

emacs常用配置-注释/反注释C++代码

2013年08月13日 ⁄ 综合 ⁄ 共 450字 ⁄ 字号 评论关闭

.emacs配置如下:

(defun qiang-comment-dwim-line (&optional arg)
  "Replacement for the comment-dwim command."
  (interactive "*P")
  (comment-normalize-vars)
  (if (and (not (region-active-p)) (not (looking-at "[ \t]*$")))
      (comment-or-uncomment-region (line-beginning-position) (line-end-position))
    (comment-dwim arg)))
(global-set-key (kbd "C-;") 'qiang-comment-dwim-line)

备注:

使用Ctrl+; 组合键,当光标放在行的始端,或者行的中间位置,即为注释该行代码

当光标放在行的末端,即为给该行代码添加注释。

效果如下图:

参考链接:

抱歉!评论已关闭.