vscode-emacs-mcx
vscode-emacs-mcx copied to clipboard
The mark set by Control+Space is moved when trying to select words with Control+Left/Right
I usually set marks with Control+Space to start selecting code. Then press Control+Left or Right to select whole words. This works in emacs, but with this extension, the mark seems to change location instead of letting me select words.
If I set a mark and then use Control+A or Control+E, it correctly selects from the mark to the beginning or end of the line. Control+Left/Right should have the analogous behaviour :-)
Similarly, I usually use Control+Up and Control+Down to select whole paragraphs after setting a mark in emacs. VS Code moves the scroll bar instead.
I can't work on it soon because currently I only have macOS environment where ctrl + left/right are assigned to other functionality. I appreciate if you add new keybindings that work on your environment for this purpose and create a pull-request.
A workaround is to configure the command for those keybindings. Below works for me (place it in your keybindings.json
file):
{
"key": "ctrl+left",
"command": "emacs-mcx.backwardWord",
"when": "editorTextFocus && !config.emacs-mcx.useMetaPrefixMacCmd"
},
{
"key": "ctrl+left",
"command": "-cursorWordLeft",
"when": "textInputFocus && !accessibilityModeEnabled"
},
{
"key": "ctrl+right",
"command": "emacs-mcx.forwardWord",
"when": "editorTextFocus && !config.emacs-mcx.useMetaPrefixMacCmd"
},
{
"key": "ctrl+right",
"command": "-cursorWordEndRight",
"when": "textInputFocus && !accessibilityModeEnabled"
}
This will remove the standard mapping for Ctrl + left/right
and then set them to be the same as what Alt + b/f
is set to.
To add on to the feature request, could we also get support for moving to the next blank line up or down with mark support per @marcus-lundgren workaround. So we can round out movement with the up and down keys and not just left right word
{
"key": "alt+up",
"command": "cursorMove",
"args": {
"to": "prevBlankLine",
"select": false
},
"when": "editorTextFocus"
},
{
"key": "alt+down",
"command": "cursorMove",
"args": {
"to": "nextBlankLine",
"select": false
},
"when": "editorTextFocus"
},
Development note:
- For
C-<left>
andC-<right>
, we should implementleft-word
andright-word
and assign them.M-<left>
andM-<right>
should also so as described atthis document.- These are same as
backward-word
andforward-word
in left-to-right languages, and VSCode is not supporting RTL (https://github.com/microsoft/vscode/issues/86667), so we can simply use these.
- These are same as
- For
C-<up>
andC-<down>
, it looks like they are assigned tobackward-paragraph
andforward-paragraph
on my local Emacs, but they are not documented. These commands are currently assigned toM-{
andM-}
.
C-<left>
, C-<right>
, C-<up>
, C-<down>
are available with v0.47.0
vscode default functions has the following bindings, which are overridden by this change.
{ "key": "ctrl+left", "command": "workbench.action.navigateBack" },
{ "key": "ctrl+right", "command": "workbench.action.navigateForward" }
Is there an alternative/replacement way to trigger workbench.action.navigateBack? @whitphx
@youyuanwu How about adding the following snippet to your keybindings.json
? See https://code.visualstudio.com/docs/getstarted/keybindings#_removing-a-specific-key-binding-rule
{
"key": "ctrl+left",
"command": "-emacs-mcx.backwardWord",
"when": "editorTextFocus"
},
{
"key": "ctrl+right",
"command": "-emacs-mcx.forwardWord",
"when": "editorTextFocus"
},
BTW, what OS, VSCode version, etc, are you using? I could not find those default settings on my env below (copied from the "Code" menu -> "About Visual Studio Code"):
Version: 1.74.1 (Universal) Commit: 1ad8d514439d5077d2b0b7ee64d2ce82a9308e5a Date: 2022-12-14T10:33:40.793Z Electron: 19.1.8 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Darwin arm64 22.2.0 Sandboxed: No
@whitphx vscode info:
Version: 1.74.2 (user setup)
Commit: e8a3071ea4344d9d48ef8a4df2c097372b0c5161
Date: 2022-12-20T10:29:14.590Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.22621
Sandboxed: No
The removing key binding did not work. But I added the override in the same keybinding json and it worked:
{ "key": "ctrl+left", "command": "workbench.action.navigateBack" },
{ "key": "ctrl+right", "command": "workbench.action.navigateForward" }
Would do accept some other replacement binding for those 2 commands? Visual Studio (not code) uses "ctrl+-" for naviagteBack and "ctrl++" for navigate forward.
@youyuanwu Hi, thank you for the info.
Would do accept some other replacement binding for those 2 commands?
Yes, and your suggestion makes sense.
FYI, on my Mac VSCode, ctrl+-
is already assigned to workbench.action.navigateBack
, while ctrl++
(ctrl+shift+=
) is not assigned to any command, regardless of which we should assign them at the extension level.
@youyuanwu Would you like to work on it and create the PR? If not, I can do it too.
@whitphx created PR. But tested ctrl+- and ctrl++ does not work on windows during manual testing. Alternative bindings used in the PR.