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
    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. – Austin Hemmelgarn Sep 17 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 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 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 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. – Carson Graham Sep 18 at 2:45

10 Answers 10

18

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

| improve this answer | |
  • Notepad++ only? – Hannu Sep 16 at 16:30
  • 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 – Jon Bentley Sep 17 at 8:47
  • @Hannu no, turned out it also works in GEdit and Mousepad. – R St Sep 17 at 17:24
  • 1
    Works in plain Notepad too – Wasif Hasan Sep 18 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 windows, "native" 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.

| improve this answer | |
  • 1
    Yes, but that was what the OP asked "I'm mostly interested in Notepad++" – DavidPostill Sep 16 at 16:31
  • 10
    @rexkogitans "nerd-like defamation" is a wild exaggeration. The answer makes clear why it gives the differentiation by giving a Linux CLI example which differs. There's no need to be so sensitive about it. – Jon Bentley Sep 17 at 8:39
  • 6
    Emacs uses C-k for this operation. – Pål GD Sep 17 at 8:43
  • 3
    @JonBentley "Some editors mimick Windows" is plain wrong. If you write a simple Hello World GTK program containing an input field, it will have the "Windows" shortcut by default. It's more the non-GUI editors that evolved differently in an era long before Windows. – rexkogitans Sep 17 at 9:04
  • 2
    @rexkogitans: Not everyone (I'm tempted to say hardly anyone :-)) who works in Linux uses built-in GUI text editing for actual text editing. Either you will use a dedicated GUI app (such as an IDE), or you have terminal windows running text-mode editors. – jamesqf Sep 18 at 2:21
33

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

| improve this answer | |
  • 5
    For those who care, so will d$, though that's one more keystroke. – Austin Hemmelgarn Sep 17 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> – Chris Petheram Sep 17 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. – Rhialto supports Monica Sep 17 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 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

| improve this answer | |
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.

| improve this answer | |
  • =) you forgot the Linux part! – Hannu Sep 16 at 16:21
  • @Hannu I am not currently on any Linux environment, So i can't say, but it works on any text editor/word processor in Windows, I have tested on Notepad++, plain Notepad, Microsoft Word and LibreOffice Writer. – Wasif Hasan Sep 16 at 16:23
  • @WasifHasan Why not use the built in shortcut? See my answer – DavidPostill Sep 16 at 16:24
  • Hi @DavidPostill, +1 for the answer, I didn't knew about the shortcut before! – Wasif Hasan Sep 16 at 16:26
  • 3
    "any visual text editor." - This doesn't work in the popular gVim visual editor in Windows 10. – RedGrittyBrick Sep 17 at 18:35
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.

| improve this answer | |
  • 3
    You can Fn+Right for the 'End' key – mcalex Sep 17 at 5:26
  • @mcalex Good to know thanks. – DarcyThomas Sep 17 at 9:09
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.

| improve this answer | |
0

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

CudaText+

| improve this answer | |
  • 4
    Ctrl-k comes from Emacs (and possibly Teco) – Jasen Sep 17 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 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.

| improve this answer | |
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).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.