The cursor may stay in the middle of the line and there may be necessity to delete whatever stands from the right side of the cursor, but only till the end of current line. I don't know how this called properly and if there is such function in text editors, but if there is such, what shortcut usually used for this? I'm mostly interested in Notepad++.
10 Answers
Delete to end of line
In Notepad++ it is the following shortcut:
CtrlShiftDelete Delete to end of line
-
13Since you've asked "why not use the built-in Notepad++ shortcut" on a few other answers, I'll offer a couple of reasons: (1) the built-in shortcut is only slightly quicker than shift+end, delete, (2) using the universal one means your muscle-memory will be applicable in almost every other application, (3) the universal method can be more fine-tuned e.g. shift+end+left, delete to delete to almost the end of the line Commented Sep 17, 2020 at 8:47
-
-
1
"Delete to end of line"
Windows, try this:
Hold SHIFT and hit End (selects the text) then Delete.
Linux, some editors mimick (i.e. 'works' the same as) windows editors, "native editors" (especially those running in shell/terminal) e.g. nano (pico) usually differ:
First press ENTER to split the line, creating a new line with the end part of the previous, then hold CTRL and hit k to kill the line.
In Vim, D
in normal mode will delete to the end of the current line.
-
5For those who care, so will
d$
, though that's one more keystroke. Commented Sep 17, 2020 at 11:32 -
1@CGCampbell I'm using a Vi emulator so it may have some differences but my vimrc file allows
nnoremap
where n is (presumably) normal mode and when in eg visual mode you can execute a command as if you were in normal mode using:normal <myCommand>
Commented Sep 17, 2020 at 14:09 -
@CGCampbell I think "plain old vi on Linux" has always been vim. The original Vi was always encumbered software.
:help
in Vim will list various mode names, including Normal mode (which indeed is called Command mode in Vi; that paper is the closest version I can find quickly to the original Vi reference manual. Commented Sep 17, 2020 at 20:32 -
I've removed my comments as I was wrong to point out what I did. The standard 6 modes in vim are: Normal, Insert, Replace, Visual, Visual-block and Command-line, so this a fine answer. Commented Sep 18, 2020 at 11:40
I can highly recommend Emacs-keybindings. It takes some getting used to, but it's worth it: you never have to move your hands aways from the main keyboard block (letters and numbers) which is very ergonomical: Moving your hands back and forth plays a major role in carpal tunnel's.
Another upside is that a subset of Emacs keybindings are default in bash.
Emacs keybindings are available for example in Eclipse or Visual Studio Code via plugins.
Anyway, deleting the rest of the line in Emacs is: CTRL+k
It's easy and will work in most visual text editor. Just place the cursor from where text needs to be deleted, then press SHIFT+END, release pressed keys, then hit BACKSPACE. From the cursor to the end of line is deleted.
To erase the whole remaining part of document after cursor, press SHIFT+CTRL+END, release pressed keys, then hit BACKSPACE.
I use Windows on a MacBook (there is no end key) and this is what works for me.
SHIFT+CTRL+Right arrow, release pressed keys, then hit DELETE.
This selects everything to the right of the cursor and then delete removes it.
-
3
Let's make this Retrocomputing. WordStar - we're talking at least back to 1983 (classic WordStar 3.3):
CTRL+Q then hit Y.
In other words, this is not a new feature.
I still use WordStar keystrokes in VEDIT. Old habits (yes, back to the 1980s) die hard.
Apple
Delete to End of Paragraph: CntlK
Use Cntl-K
(sometimes denoted as ^k
) to delete text to the end of the paragraph (i.e. deletes text to the next newline character).
This works for Apple applications like TextEdit and Xcode.
In emacs (and clones/workalikes) it is ctrl-K (if at the very end of the line, this deletes the line end). emacs has its full extension language, with which you can write really anything and bind it to a shortcut, up to "modes" for working with different file types (languages) and running external commands.
In vi (and it's clones) "D" or "d$" (Omit the quotes! "Delete to end of line", also "delete" d + "move to end of line" $). vi has a very rich command set with base commands that can be composed, even calling out to operating system commands. Current vi clones (the most likely to be found today, on Linux original vi --closed source-- would be a no-no) sport their own elaborate extension language(s).
Escape
(to go out of Insert mode into Normal mode) and then doingd$
. I imagine there are bindable shortcuts for GUI editors too but if you give Vim a go I have a feeling you'll want to stick with it :)d$
as QuickishFM mentioned will delete (d
) from the cursor to the end of the line ($
). However, I believeD
will delete the entire line, starting at the cursor and ending at the end of the line. So, that's a 1-key command when in normal mode, which is what vim users are in most of the time.