MacOS – Remapping “Command + Arrow Key” to jump through the words of CamelCase expressions

cursorkeyboardmacos

I often go through sentences word-by-word, using Command+Arrow Keys.

However, when there is a word in camel case (e.g. "AppleForumsQuestion.txt", in filenames or so), that won't work – Command+Arrow Keys only snaps to spaces.

Is there any (system-wide, ideally) way to make it move the cursor to the individual "words" of also camel-case expressions?

Best Answer

⌃← and ⌃→ do that by default in many code editors like Xcode, TextMate, Sublime Text, and BBEdit. (If you have disabled the shortcuts for changing desktops.) You can change the shortcuts in TextMate by overriding KeyBindings.dict.

I have tried adding something like this to DefaultKeyBinding.dict:

"^\UF702" = moveSubWordLeft:; // control-left
"^\UF703" = moveSubWordRight:; // control-right

It doesn't work in other applications though. And ⌘← and ⌘→ can't even be reassigned in DefaultKeyBinding.dict.