14

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++.

9
  • 9
    Strictly speaking, there is but it's not really a shortcut. For pretty much all GUI-based editors, you can hold <kbd>Shift</kbd>, hit <kbd>End</kbd> and then hit <kbd>Delete</kbd>. This is no different from just manually selecting the text with the mouse and deleting it. Sep 17, 2020 at 11:31
  • Different text editors will have different commands for this. Good ones will let you assign the function to whatever key you prefer. In my editor, I've assigned it to Shift-End.
    – jamesqf
    Sep 17, 2020 at 17:17
  • Practically, all programmer's editors do this. It may not be assigned by default but you can assign your own keyboard combination to it. And also to delete from cursor position to the start of the line.
    – Gábor
    Sep 17, 2020 at 17:58
  • 2
    If you want to give Vim a go (yes, its available on Windows) then you can do all sorts of things, much more powerful than Notepad++ (in terms of ability out of the box) but there is a fairly steep learning curve. With vim its as easy as hitting Escape (to go out of Insert mode into Normal mode) and then doing d$. 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 :)
    – QuickishFM
    Sep 17, 2020 at 18:50
  • 3
    If I remember correctly, there are several ways to do this in vim. d$ as QuickishFM mentioned will delete (d) from the cursor to the end of the line ($). However, I believe D 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. Sep 18, 2020 at 2:45

10 Answers 10

19

Delete to end of line

In Notepad++ it is the following shortcut:

CtrlShiftDelete Delete to end of line

Source: Notepad++ Keyboard Shortcuts - Virendra's Techtalk

3
  • 13
    Since 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 Sep 17, 2020 at 8:47
  • @Hannu no, turned out it also works in GEdit and Mousepad.
    – R St
    Sep 17, 2020 at 17:24
  • 1
    Works in plain Notepad too
    – Wasif
    Sep 18, 2020 at 7:30
34

"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.

0
33

In Vim, D in normal mode will delete to the end of the current line.

4
  • 5
    For those who care, so will d$, though that's one more keystroke. 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> 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. 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.
    – CGCampbell
    Sep 18, 2020 at 11:40
7

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

6

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.

0
4

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.

1
  • 3
    You can Fn+Right for the 'End' key
    – mcalex
    Sep 17, 2020 at 5:26
4

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.

0

CudaText editor (free) has command named "Delete to line end". Hotkey is Ctrl+K. Hotkey is customizable of course.

CudaText+

2
  • 4
    Ctrl-k comes from Emacs (and possibly Teco)
    – Jasen
    Sep 17, 2020 at 8:16
  • @Jason, I remember little of TECO, but it was all printable ASCII character commands. Looked like line noise for the uninitiated.
    – vonbrand
    Sep 19, 2020 at 20:10
0

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.

0

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).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .