Delete whitespace left and right in Notepad++

8

In Notepad++, is there a hotkey to wipe all white space left and right of the cursor?

I'd imagine it would be the same as "delete current word", but I can't find it.

  • Ctrl + Del deletes to the end of the word
  • Ctrl + Backspace deletes to the beginning of the word

MrSparkly

Posted 2011-04-29T06:12:34.457

Reputation: 223

Answers

14

There is no shortcut by default, but you can easily add one using the shortcut mapper. The action to remove leading and trailing space is found in Edit > Blank operations > Remove leading and trailing space

You can map it by going to Settings > Shortcut Mapper... > Then scrolling to whichever one you want (such as 29) and double clicking on the cell under Shortcut.

That0therguy

Posted 2011-04-29T06:12:34.457

Reputation: 544

1"Remove leading and trailing space" drops those from the whole document, which is not what this question is about. – Gonen – 2013-11-19T09:35:06.177

2

I didn't find the actions you've asked for,
but could suggest a simple search-and-replace pattern:

Search: \h+(\w+)\h+
Replace: _$1_ (the '_' character here represents a blank character)

You could also write a short macro for that -
see here for a list of predefined Notepad++ shortcut-keys:

Lists of default mouse and keyboard shortcuts for Notepad++ and some plugins

Gonen

Posted 2011-04-29T06:12:34.457

Reputation: 121