Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Meta/Super/Option instead of Control Key for Ctrl Key based vim Operations #3301

Open
vignesh0025-zz opened this issue Dec 28, 2018 · 12 comments

Comments

@vignesh0025-zz
Copy link

Problem
Many important shortcuts are mapped to Control Key in VSCode by default and at the same time, Control Keys play a important role in Vim Operations. I can't ditch control keys in favour of VSCodeVim or the other way also. I got this issue as I am moving from Mac to Linux where is no Command Key and Ctrl key like options.

Idea
So instead of completely relaying on Ctrl keys, Meta/Option keys can be used for Vim operations instead of control keys. Like for Example, Meta+s to split the editor instead of "Ctrl+s".

Alternatives
I tried to implement this myself but it seems like all shortcuts are hard coded in package.json. Besides, I couldn't understand the code due to lack of documentation. If this idea is not taken or seems useless, please just guide me where to start so that, I would implement it someday as per my need.

Additional Context
I got this problem while switching from Mac to Linux based OS (Debian). In Mac, Almost all VSCode
operations use Command Key and Control key is left unused. In that scenario, VsCodeVim taking full control over Ctrl Key seemed very very effective. I am not losing any functionality of vim and at the same time, all VSCode specific shortcuts are working via Command Key.

@jpoon
Copy link
Member

jpoon commented Dec 30, 2018

I got this issue as I am moving from Mac to Linux where is no Command Key and Ctrl key like options.

I haven't used a Linux machine in awhile, but I recall them understanding the Ctrl key. The documentation for VSCode also lists the same: https://code.visualstudio.com/docs/getstarted/keybindings#_accepted-keys

Like for Example, Meta+s to split the editor instead of "Ctrl+s".

I'm not really sure of a good way of doing this. At the moment, we don't bind to the meta keys which means we [vscodevim] does not get any notification of those key presses. For our keybindings see: https://github.com/VSCodeVim/Vim/blob/master/package.json#L141

@vignesh0025-zz
Copy link
Author

vignesh0025-zz commented Dec 31, 2018

Hi jpoon,
Actually, I made the required changes and got it working as I expected. You can find the changes here in the last commit.
https://github.com/vignesh0025/Vim/tree/MetaKeySupport
But I don't feel its the right way to do and so, I didn't create any pull request for the same. Kindly give your suggestion about the changes

@vignesh0025-zz
Copy link
Author

I haven't used a Linux machine in awhile, but I recall them understanding the Ctrl key. The documentation for VSCode also lists the same: https://code.visualstudio.com/docs/getstarted/keybindings#_accepted-keys

Linux machines understand Alt and Ctrl Key. Apart from that, Windows key is also understood as Meta Key which usually is mapped to system related functions like 'WinKey+L' to lock the screen

@taylon
Copy link

taylon commented Jan 4, 2019

My use case is different, but I would love to be able to use the Meta/Super keys as a modifier for keybindings as well.

If I understood @vignesh0025 correctly, just binding Meta/Super and exposing it as a usable key would fix his issue as well, since VSCode can handle it, I was expecting to be able to use those for configuring vscodevim too.

@symonds
Copy link

symonds commented Mar 5, 2019

I would like an option to use ALT instead of CTRL for vim keybindings, that way they wouldn't class with any vscode or my window manager bindings.

I've done this by rebinding one at a time, but I can imagine this would be a nice option for others.

@elcritch
Copy link

Similar question, but is it possible to instead change the default VSCode "ctrl key" to a user customizable option? I like to map save from "ctrl-s" to "meta-s" on Linux as much as possible. It seems @vignesh0025 's change modifies the Vim mappings instead?

@max-sixty
Copy link
Contributor

I've just moved from Mac to Linux for a new job.

VSCodeVim on a Mac was particularly good because the common OS & VSCode combinations were on the Cmd key, leaving the Ctrl key mostly free for the Vim extension.

Now the common OS & VSCode combinations on Linux use Ctrl, there are lots of OS & VSCode <> Vim conflicts. There are very few existing Alt+[a-z] mappings in VSCode. So if VSCodeVim could have a setting to change its Ctrl mappings to Alt (similar to @vignesh0025's changes, but a user setting), that would solve those problems in one go. (OTOH you'd have different combinations to those in actual Vim, but that's a tradeoff)

Tangentially related: #2713

Thanks for the awesome extension!

@vtvh
Copy link

vtvh commented Sep 20, 2020

Thanks for all the great efforts. 🙏

Looking forward for the ability to binds Alt/Meta keys. Although <Leader>+<n^n> key would be enough for everyone for now.

@ghost
Copy link

ghost commented Oct 14, 2020

My preferred rebind would be:

VSCodeVim: CTRL
VSCode: Shift-CTRL

i.e. All Vim CTRL commands use CTRL. All VSCode CTRL commands remapped to Shift-CTRL.

This should avoid clashing with existing bindings to Meta and Alt.

@sethlivingston
Copy link

Slightly different use case here. I just switched from Linux to a Mac, and hitting the Control key feels like I'm breaking my pinky (whiny, I know). I'd like to switch to the Command key for Vim bindings even though they'll conflict more with native Mac bindings. It's just faster and more comfortable for me.

Thank you for the extension!

@mangkoran
Copy link

Is this feature going to be implemented? Pretty much most of vim users highly utilize key bindings, and these key binds are the core of vim.

@pawellysy
Copy link

+1 from me! On the other hand, is there a built in way of remapping the ctrl to meta in VS Code base preferences/settings page?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants