2

Xcode inserts an invisible character whenever I press Ctrl+X, Ctrl+S (was trying to save the code but then realised that I am not using Emacs and should use command+S instead, and went back to delete the festy character.) Deleting something that is invisible is not fun, so.

Is there a way I can disable this "feature"? And by that I mean make Xcode stop inserting the character and essentially does nothing when I press the key combination. I am not looking for a full Emacs key binding setting for Xcode.

2 Answers 2

3

I don't think this is possible in Xcode.

This happens because ctrl+x indicates to Xcode that you want to type one of the ASCII control characters. The next thing you type tells it which one. Pressing ctrl+s inserts an ASCII 19, "device control 3". Different letters insert different control characters-- see the chart at that link for a full list. Control characters are not printable, so it's invisible. Unfortunately Xcode's option to show invisibles (Edit menu --> Invisibles) doesn't show ASCII control characters, so you end up with something Xcode doesn't like but that you can't see.

You might be able to use Karabiner to deal with this, I'm not sure though.

1

Karabiner is free, but it is a little complicated to add a per-application rule. You need to create an entry for a "Complex Modification" written in JSON, in ~/.config/karabiner/karabiner.json. See karabiner.json Reference Manual

Another option is BetterTouchTool. It's not free, but is easier to configure, and has many other features. In the preferences, you would do this:

  1. Add Xcode in the application sidebar
  2. Click the Keyboard tab
  3. Click "Add New Shortcut or Key Sequence"
  4. Press control-X in the Shortcut box
  5. Leave the "Trigger Predefined Action" at "No Action".
1
  • I'm using BetterTouchTool to enable some Emacs key sequences in XCode, BTW
    – Alex Lokk
    Commented Apr 6, 2020 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .