In Emacs, there's a handy command called
It marks the rest of the current s-expression from the cursor's position.
It's mapped to
C-M-SPC (ctrl + meta + space) by default, which is compatible with terminal applications.
However, if you have option key mapped to
+Esc in iTerm2, pressing ctrl + option + space is interpreted as meta + space instead.
To fix this, you need to add an additional keybinding to your session's key bindings.
- In iTerm2, open: Preferences > Profiles > some session you wish to edit > Keys.
- Add a new key binding by pressing the "+" button.
- Select the "Keyboard Shortcut" field, and press ctrl + option + space.
- Select "Send Hex Code" in the "Action" list.
- Type "0x1b 0x00" to the field below the list.
- Click OK and close the preferences window.
C-M-SPC now works in all the new terminal windows that use the edited session.
You can also make the same changes for running terminals by editing the running session.