I want to delete all the lines below a particular line of emacs ? Is there any shortcut key which can delete all the lines below a particular line?
How to delete all the lines in one go in emacs?
You are kind of missing the point of using a programmable, extensible editor if you want to restrict yourself to predefined key bindings. –
Theism
C-u 9999999 C-k
should do the trick.
If you are not at the beginning of the first line you want to kill, then use C-a C-u 9999999 C-k
.
(The 9999999
can be any number larger than the number of lines you want to kill.)
An alternative to using C-u 999999
is to hold down the Control
key and then hold down 9
, so you get, in effect: C-9 C-9 C-9 C-9 C-9 C-9 C-9 C-k
.
Try again. Unless you have something in your init file (
~/.emacs
) that changes things it will work. To be clear, C-a
means press and hold Control
while hitting a
, and so on. –
Josie actually the number 1000 was being displayed as 1 0 0 0 so i thought it was working for single digits but that was not the case and it deleted 1000 lines –
Hedonics
Using
9
s instead of 1
s and 0
s means fewer keystrokes. ;-) –
Josie Just add this function to your ~/.emacs
:
(defun kill-to-end-of-buffer() "Deletes all lines after the current line"
(interactive)
(progn
(forward-line 1)
(delete-region (point) (point-max))))
;; Change this to your preferred keybinding
(global-set-key "\C-\M-k" 'kill-to-end-of-buffer)
Incredibly convenient. Thank you! –
Kiwanis
To delete all the lines in one go you can use C-x r t space. Makes a string rectangle! Check this link for more info on how to specialize this for your needs.
© 2022 - 2024 — McMap. All rights reserved.