Archive

Posts Tagged ‘comment’

emacs commenting lines

July 1st, 2011 No comments

I was wondering if the comment-dwin (M-;) command could be changed that if i am anywhere in the line the whole line is commented and not a comment started from the end of the line. based on the idea found in a mailing list i altered the command with

;; http://www.opensubscriber.com/message/emacs-devel@gnu.org/10971693.html
(defun comment-dwim-line (&optional arg)
  (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 "\M-;" 'comment-dwim-line)

add this to your .emacs file and enjoy.

Categories: IT
Tags: , ,
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...