Sublime does exactly that by default, doesn’t it? ctrl
modifier moves and removes words and any amount of whitespace.
The primary difference between ST and any other Windows application is the way it positions carets when moving caret word-wise.
ST prefers to position caret at the end of words when moving rightwards and to word begins, when moving leftwards, to enable quick selection and removal of whole words (without leading or trailing whitespace).
All other Windows Apps (such as Notepad/Notepad++) always keep caret at word begins, thus always remove whitespace and following/preceding words (or vice versa). You can’t therefore easily remove words without surrounding spaces.
If you prefer the “Windows” style of caret movement you might want to try following user specific key bindings.
Note: They are enabled by "windows_caret_movement": true
in Preferences.sublime-settings.
[
// Windows Style Word Navigation
// (caret is always moved to beginning of words)
{ // move caret to beginning of previous word on the left
"keys": ["ctrl+left"],
"command": "move", "args": {"by": "words", "forward": false},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
{ // move caret to beginning of next word on the right
"keys": ["ctrl+right"],
"command": "move", "args": {"by": "words", "forward": true},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
{ // select everything including previous word on the left
"keys": ["ctrl+shift+left"],
"command": "move", "args": {"by": "words", "forward": false, "extend": true},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
{ // select everything to next word on the right
"keys": ["ctrl+shift+right"],
"command": "move", "args": {"by": "words", "forward": true, "extend": true},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
{ // delete everything including previous word to the left
"keys": ["ctrl+backspace"],
"command": "chain",
"args": {
"commands": [
{ "command": "move", "args": {"by": "words", "forward": false, "extend": true } },
{ "command": "right_delete" }
]
},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
{ // delete delete everything to next word on the right
"keys": ["ctrl+delete"],
"command": "chain",
"args": {
"commands": [
{ "command": "move", "args": {"by": "words", "forward": true, "extend": true} },
{ "command": "left_delete" }
]
},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
// Windows Style Subword Navigation
// (caret is always moved to beginning of sub-words)
{ // move caret to previous sub-word on the left
"keys": ["alt+left"],
"command": "move", "args": {"by": "subwords", "forward": false},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
{ // move caret to next sub-word on the right
"keys": ["alt+right"],
"command": "move", "args": {"by": "subwords", "forward": true},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
{ // select sub-word to the left
"keys": ["alt+shift+left"],
"command": "move", "args": {"by": "subwords", "forward": false, "extend": true},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
{ // select sub-word to the right
"keys": ["alt+shift+right"],
"command": "move", "args": {"by": "subwords", "forward": true, "extend": true},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
{ // remove sub-word to the left
"keys": ["alt+backspace"],
"command": "chain",
"args": {
"commands": [
{ "command": "move", "args": {"by": "subwords", "forward": false, "extend": true } },
{ "command": "right_delete" }
]
},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
{ // remove single space/tab at bol instead of all whitespace
"keys": ["alt+backspace"],
"command": "chain",
"args": {
"commands": [
{"command": "move", "args": {"by": "characters", "forward": false, "extend": true} },
{"command": "right_delete" }
]
},
"context": [
{ "key": "setting.windows_caret_movement" },
{ "key": "preceding_text", "operator": "regex_match", "operand": "^[ \t]+$", "match_all": true }
],
},
{ // remove sub-word to the right
"keys": ["alt+delete"],
"command": "chain",
"args": {
"commands": [
{ "command": "move", "args": {"by": "subwords", "forward": true, "extend": true} },
{ "command": "left_delete" }
]
},
"context": [
{ "key": "setting.windows_caret_movement" }
]
},
]