\ Dexter's Laboratories » emacs commenting lines
Home > IT > emacs commenting lines

emacs commenting lines

I was wondering if the -dwin (M-;) command could be changed that if i am anywhere in the line the whole line is commented and not a 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 . file and enjoy.

Categories: IT
Tags: , ,
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
2,161 views
  1. No comments yet.
  1. No trackbacks yet.