How to toggle between vim-emulation and no-vim-emulation when the vscodevim extension is installed?
Asked Answered
C

3

46

I haven't found a way to quickly do this without having to entirely disable the extension in the "Extensions" panel. In IntelliJ IDEA, one can easily toggle on/off the emulation with a configurable keyboard shortcut. I guess it should also be possible in VSCode.

Caresa answered 26/11, 2017 at 23:59 Comment(0)
C
62

VSCode has the same command system as atom. These commands can be started through the "command palette" and also bound to a key-combo.

The corresponding command is toggleVim. You can bind this command to a key using the gear-icon > keyboard combos (sry, i don't know how to switch the language for an exact description :) ) > enter "toggleVim" to the searchbar. Then you can assign a combo to it.

Effectively the extension will be disabled or enabled quickly.

Contractive answered 20/12, 2017 at 21:59 Comment(1)
In English, these are "shortcuts": Manage (the "gear" icon) > Keyboard Shortcuts > Vim: Toggle Vim ModeMarconigraph
T
48

This answer is an extension to the previous answer.

You can use a keyboard shorcut for toggleVim command with the help of keybindings in VS code.

For example, here I want to use Ctrl+Alt+V to toggle Vim mode on/off. To do this I add the following to keybindings.json and save the file.

    {
        "key": "ctrl+alt+v",
        "command": "toggleVim"
    }

You can open keybindings.json from command palette Ctrl+Shift+P, >Preferences: Open Keyboard Shortcuts (JSON).

Please note, you have to be careful to choose only from unused keybindings in Vim and VS code. Alt key combinations are unused in Vim.

Tetrode answered 7/5, 2020 at 8:3 Comment(1)
***** Five stars for this thanksStaysail
J
4

I don't know if this is a new feature within VS Code's user interface (UI), but with VS Code v1.78.2 you can use the UI to assign a user-defined keyboard shortcut to the command toggleVim. Here's how:

  1. File menu > Preferences > Keyboard Shortcuts [Ctrl+K][Ctrl+S]

  2. Search for toggleVim

  3. With the mouse, double-click on the line Vim: Toggle Vim Mode

  4. When prompted, enter the desired keyboard shortcut—e.g., ctrl+alt+v— and then press ENTER to save this change.

At the bottom of the VS Code window, in the status bar, you'll see either -- VIM: DISABLED -- or -- NORMAL -- (i.e., Vim enabled) after pressing the chosen keyboard shortcut for the toggleVim command.

Javier answered 12/5, 2023 at 15:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.