103

Eclipse has a keyboard shortcut which deletes either the current line (if nothing is selected) or all lines which are part of the currently selected text: Ctrl+D.

Is there a way to make Ctrl+D do the same thing in Notepad++?

The best I could do is remap the shortcut to Scintilla's SCI_LINE_DELETE, but that only deletes one line at a time, even if the selection spans multiple lines.

Matt Ball
  • 3,912

9 Answers9

123

Ctrl + Shift + L will achieve the same effect.

Ctrl + L will delete the line but will also keep it in your clipboard replacing clipboard contents.

I'm not sure if you can map Ctrl+D to do the same thing or not. I've not really messed with the keyboard mappings with Notepad++ since they are very similar to those of Visual Studio

Anthony Shaw
  • 1,908
26

I had to map Ctrl+D to both SCI_LINEDELETE and SCI_LINECUT in order to make it behave like Eclipse. Hope this is helpful.

You also need to disable or rebind SCI_SELECTIONDUPLICATE so there's no conflict on Ctrl+D.
To disable a shortcut, highlight it, click Modify set the DropDownList to None, click Apply first and then Okay.

mrd
  • 3
alex
  • 261
16

Macro is a good choice here. Though the macro I came up with lags a bit (you can see may be quarter of a second lag between CTRL-D hit and lines getting deleted on a large selections) it works grand both on a single line and multiple lines selection and covers various tricky cases.

So, my macro is:

CTRL + J - if multiple lines are selected they are joined into a single line
HOME - the usual HOME button. Brings cursor to the start of a line (or start of a joined line)
SHIFT + END - selects the line till the end starting from the cursor position
CTRL + SHIFT + L - deletes the whole line

This set of actions covers all possible scenarios of line deletion I have encountered so far during heavy use of notepad++.

11

There is a shortcut in Notepad++ to delete a line: Ctrl+Shift+L ..but this will only delete a single line.

Even if several lines are selected, it will only delete the line where the cursor is resting and not the highlighted lines.

So, the simplest way to delete a series of selected lines, you have to Record a Macro with these key shortcut combinations:

Ctrl+J

followed by

Ctrl+Shift+L

This will first JOIN the selected lines and then DELETE the whole line.

This is better than using a combination of CUT and DELETE approach as mentioned above (which i've tried) because on some instances, it will also delete non-selected lines.

soandos
  • 24,600
  • 29
  • 105
  • 136
8

As a non-macro alternative to @Jan Domozilov's answer, I followed these steps (using Notepad++ v6.5.1 (UNICODE)):

  1. In the Settings menu, select Shortcut Mapper.
  2. In the Main menu tab, set Join Lines (line 26) to Ctrl+Alt+D.
  3. Click the Scintilla commands tab.
  4. Set SCI_LINEDELETE (line 90) to Ctrl+D.
  5. Close the window.

This allows you to perform the desired behavior with a small modification. You select your text, run the Join Lines command with Ctrl+Alt+D, release only the Alt key, and press D again to delete the text.

nikodaemus
  • 2,883
0

One other simpler way is to use the backspace button after selection, this will replace selected line with backspace.

0

What you can do to make Notepad++ behave more like Eclipse is to:

  1. Map SCI_SELECTIONDUPLICATE to Ctrl+Alt+Down (or Ctrl+Alt+Up)

enter image description here

  1. Map SCI_LINEDELETE to Ctrl+Alt+Down (or Ctrl+Alt+Up):

enter image description here

There is BTW a file called shortcuts.xml in the root of the installation folder where these changes can be found. I wouldn't rely on copying this file around however, since I've had problems with that approach installing the same shortcuts on more than one computer.

Kawu
  • 136
  • 10
-1

You can use CTRL+DELETE to delete the entire content of a line. Then all you do is use DELETE again to remove the line feed. If that is not enough for you, you can create a macro to do both actions.

As it seems to have stopped working in the latest version, I recommend you to use the Macro approach for the entire problem. Go to Macro, "Start Recording", then press "Home", "Shift"+"END", "DELETE", "DELETE", then go to Macro and stop your Macro. After that, go to Save Current Recorded Macro" and chose a name and shortcut, (e.g. CTRL+DEL). This reenables the shortcut for delete line.

private_meta
  • 2,474
-2

CTRL+SHIFT+DELDETE works for me great to delete whole single line.

Zuzu
  • 7