MacOS – Xcode delete subword/word forward/backword eating empty space

keyboardmacosxcode

This is really weird behaviour. Any editor I use treats empty space as a word and does not skip it. By empty space I mean newlines, tabs, spaces, etc.

Now what was for me always just a press of one shortcut option/backspace or option/Fn/backspace is complex operation, because I want to delete just space or newline forward and it deletes also the next word there.

Example:

adadada
dada
d
adadad  ad

When I place the cursor, (in text wrangler editor, but also other editors such as android studio etc, for example) every other then Xcode actually, so when I place it at end of first line and press fn/option/backspace , then remove just new line and I press it again and then the next word is deleted. But in Xcode it remove new line with the word on the first go.

How can I tune Xcode to behave like normal source code text editor ? (yeah little confused here)

Best Answer

If I understand your question correctly given the two lines

abc^
xyz

with the cursor as the ^. You would like to know how to delete forward to achieve the following with one shortcut

abc^xyz

Again the ^ here symbolizes the text cursor.

The forward delete in xcode is mapped to both the forward delete key ("del" absent on most mac keyboards) but "fn delete" is a forward delete, "control d" also functions as delete forward. This can be changed in the xcode preferences -> keymap

enter image description here

Now to the aspect of deleting white space and newline... This is harder, it seems like xcodes subword (which selects or deletes to a capitalized section in a word), word, and expression deletes do not include whitespace.

To select just white space and newline and delete it you can do the following three commands option shift ->, option shift <-, delete I have an app called betterTouchTool that allows me to map those three commands to one single one. Not my softwware but been using it for years. It's amazing.

enter image description here