I won’t repeat myself on the usefulness of prefix arguments, though it
would hardly be an overstatement. Killing 7 lines of text in two
keystrokes is a bliss most people will never know.
Today's post was prompted by this question on Emacs Stack Exchange. Itsjeyd has
grown tired of using 3 keystrokes to kill a line (C-a C-k
C-k) and asks for an alternative. The straightforward answer is to use
kill-whole-line instead, but then you either need another keybind,
C-S-backspace, or you need to lose the regular kill-line
functionality.
The solution I've found for myself is to use prefix arguments.
You see, killing half a line is a useful feature, but slaughtering three and a
half lines make very little sense. So it stands to reason to have kill-line
meticulously murder everything in its sight when given a prefix argument.
And we bind them, of course.
With this little macro, C-k still kills from point, but
C-3 C-k swallows three whole lines. As a bonus, we get the
kill-whole-line behavior by doing C-1 C-k.
Are there any other functions which might benefit from this macro?
Kill Entire Line with Prefix Argument
19 Oct 2014, by Artur Malabarba.Emacs.SE Lessons post series
I won’t repeat myself on the usefulness of prefix arguments, though it would hardly be an overstatement. Killing 7 lines of text in two keystrokes is a bliss most people will never know.
Today's post was prompted by this question on Emacs Stack Exchange. Itsjeyd has grown tired of using 3 keystrokes to kill a line (C-a C-k C-k) and asks for an alternative. The straightforward answer is to use
kill-whole-line
instead, but then you either need another keybind, C-S-backspace, or you need to lose the regularkill-line
functionality.The solution I've found for myself is to use prefix arguments.
You see, killing half a line is a useful feature, but slaughtering three and a half lines make very little sense. So it stands to reason to have
kill-line
meticulously murder everything in its sight when given a prefix argument.And we bind them, of course.
With this little macro, C-k still kills from point, but C-3 C-k swallows three whole lines. As a bonus, we get the
kill-whole-line
behavior by doing C-1 C-k.Are there any other functions which might benefit from this macro?
Tags: keybind, init.el, emacs,
Aggressive-indent just got better! »
« Old Packages and New Packages in 24.4
Related Posts
A few paredit keys that take over the world in keybind
Fill and unfill paragraphs with a single key in keybind
Disable Mouse only inside Emacs in keybind
Content © 2019, All rights reserved. Icons under CC3.0.