Why we don't have a comment/uncomment-line function is beyond me. While we fix
that, might as well make it as complete as possible.
Short and sweet, isn't it? In analogy to M-;. I find C-; to be a great
binding for it. This way I can quickly comment 3 lines by hitting C-3 C-;.
Also, because it moves forward after commenting, you can conveniently do things
like comment every other line by repeatedly doing C-; C-n.
Update <2015-02-01 Sun>
The previous version didn't quite work for negative prefix arguments, so I've
updated the above snippet to fix that.
Also, quite a few people requested (or proposed) a version which acts on region
if active. I already use M-; for that (and I also its other modes of
operation), but I can see why people would want that so I've added it below.
It's similar to the one suggested by Kaushal Modi.
Implementing comment-line
26 Jan 2015, by Artur Malabarba.Why we don't have a
comment/uncomment-line
function is beyond me. While we fix that, might as well make it as complete as possible.Short and sweet, isn't it? In analogy to M-;. I find C-; to be a great binding for it. This way I can quickly comment 3 lines by hitting C-3 C-;.
Also, because it moves forward after commenting, you can conveniently do things like comment every other line by repeatedly doing C-; C-n.
Update <2015-02-01 Sun>
The previous version didn't quite work for negative prefix arguments, so I've updated the above snippet to fix that.
Also, quite a few people requested (or proposed) a version which acts on region if active. I already use M-; for that (and I also its other modes of operation), but I can see why people would want that so I've added it below. It's similar to the one suggested by Kaushal Modi.
Tags: programming, optimization, keybind, init.el, emacs,
New on (M)Elpa: speed-of-thought-lisp »
« New in Emacs 25.1: Easily install multifile package from a directory
Related Posts
Turbo up your Ruby console in Emacs in programming
A few paredit keys that take over the world in programming
Restarting the compilation buffer in comint-mode in programming
Content © 2019, All rights reserved. Icons under CC3.0.