VSpaceCode

by VSpaceCode

VSpaceCode /VSpaceCode

Spacemacs' like keybindings for Visual Studio Code

579 Stars 77 Forks Last release: Not found MIT License 353 Commits 10 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

VSpaceCode (Preview)

VSpaceCode Logo

This extension is inspired by spacemacs and aiming to provide similar experience in VSCode. An action menu trigger by space key is implemented to reduce memorization of shortcuts. You can change the editor group, change the file language, and check git status without leaving your keyboard. This provides the speed to shortcut while minimizing typing comparing to fuzzy search in the command palette or shortcut memorizing.

Features

  • Spacemacs like action menu to reduce memorization of shortcuts
  • All menu items are customizable
  • The menu key is customizable
  • Bundle all the extensions needed out-of-the box

VSpaceCode actions

Project history

This project was initially started by StreakyCobra as a configuration file for VSCodeVim to be merged in your

settings.json
file. stevenguh developed on his side stevenguh/spacecode also with the goal to bring Spacemacs bindings to VSCode. After some discussion we agreed to merge the two projects to keep this niche community unified. stevenguh solution was technically better, but this project had a larger community and was better referenced, so it was decided move his extension here and to deprecate stevenguh/spacecode.

If you prefer this project's first approach using settings without an extension, see the vscode-vim branch.

Installation

This extension is published as an extension pack, and should install all the necessary extensions for the best-of-the box experience; however, if you do not like the bundled extensions or are not using VSCode Vim, please go to the vscode-which-key for a standalone which key menu function.

After the installation of the extension, a notification will help you to configure both the necessary settings and user bindings. However, the formatting of

settings.json
and
keybindings.json
may be lost. You can choose to follow the manual configuration below.

Configuration

The

settings.jsonc
and
keybindings.jsonc
in the repo contains the configurations needed. You can merge them manually to your user's

settings.json
and
keybindings.json
.

You can access your user's

settings.json
and
keybindings.json
by searching
Preference: Open Settings (JSON)
and
Preference: Open Keyboard Shortcuts (JSON)
in the command palette (Ctl+Shift+P)

The following commands can be access through command palette to rerun the automatic configuration step.

  • VSpaceCode: Configure Default Settings and Keybindings

This command will run the below two commands and is also the command that runs on the welcome notification

  • VSpaceCode: Configure Default Settings

This command will merge the necessary settings to your user's

settings.json
  • VSpaceCode: Configure Default Keybindings

This command will merge the necessary key bindings to your user's

keybindings.json

Menu Customization

There are two ways to customize the menu: incrementally, and from scratch. Incrementally is great for when you only need to modify a few bindings from the default. Customizing from scratch is great for total control of the customization.

Default bindings

See KEYBINDINGS.md for default bindings.

The default menu bindings are subject to change before

1.0.0
. If you find something that you think it should bind to a particular key by default, or you want a particular command, please open an issue as a feature request.

Incrementally

Using this option will allow to you surgically update the default bindings (

vspacecode.bindings
). The extension will override bindings sequentially base on
vspacecode.bindingOverrides
.

Add/Replace

The following json will replace

 g s
in the same position if the binding exists in
vspacecode.bindings
, and append
s
to menu
 g
if it doesn't exists. This override will only execute if
 g
menu exists. An optional
position
key can be used to specified index of where the item should be inserted/moved to.
{
  "vspacecode.bindingOverrides": [
    {
      "keys": "g.s",
      "name": "Go to line",
      "type": "command",
      "command":"workbench.action.gotoLine",
    }
  ]
}

The following example will replace/append the whole

 g
menu with one binding
s
in it.
jsonc
{
  "vspacecode.bindingOverrides": [
    {
      "keys": "g",
      "name": "Go...",
      "type": "bindings",
      "bindings": [
        {
          "key": "s",
          "name": "Go to",
          "type": "command",
          "command": "workbench.action.gotoLine",
        }
      ]
    }
  ]
}
If the key binding's key uses character
.
like
 e .
, you can target that by using an array in the keys like
"keys": ["e", "."]
.

Removal

Any negative number in position is denoting a removal operation. In the following example, any item bound to

 g s
will be remove.
jsonc
{
  "vspacecode.bindingOverrides": [
    {
      "keys": "g.s",
      "position": -1,
    }
  ]
}

From Scratch

To customize the menu items from scratch, you can override the menu completely by putting your own

vspacecode.bindings
into your
settings.json
. Using this option will prevent any update to your own bindings.

An example of a

settings.json
file that overrides space menu is as follows:
json
{
  "vspacecode.bindings": [
    {
      "key": "f",
      "name": "File...",
      "type": "bindings",
      "bindings": [
        {
          "key": "f",
          "name": "Open file",
          "type": "command",
          "command": "workbench.action.files.openFileFolder"
        },
        {
          "key": "i",
          "name": "Indentation...",
          "type": "bindings",
          "bindings": [
            {
              "key": "i",
              "name": "Change indentation",
              "type": "command",
              "command": "changeEditorIndentation"
            },
            {
              "key": "d",
              "name": "Detect indentation",
              "type": "command",
              "command": "editor.action.detectIndentation"
            }
          ]
        }
      ]
    }
  ]
}

The default value can be found in the

contributes.configuration.vspacecode.bindings.default
section of the
package.json
in this repo. You can use the default value as an example to craft your own custom menu.

Bonus

This section contains additional config that might be helpful beyond the default bindings

Quick Window Navigation

To navigate all the windows including slide and bottom pane with

Ctl-h/j/k/l
, you can merge the following config system's key bindings to your
keybindings.json
file.

This config might be in conflict with "Easy List Navigation" below.

keybindings.json

[
    {
        "key": "ctrl+h",
        "command": "workbench.action.navigateLeft",
        "when": "!inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible"
    },
    {
        "key": "ctrl+j",
        "command": "workbench.action.navigateDown",
        "when": "!inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible"
    },
    {
        "key": "ctrl+k",
        "command": "workbench.action.navigateUp",
        "when": "!inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible"
    },
    {
        "key": "ctrl+l",
        "command": "workbench.action.navigateRight",
        "when": "!inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible"
  }
]

Easy List Navigation

Although VSCode Vim already bound these to

h/j/k/l
, however, they might not work in all lists like in the problem pane. You can merge the following keybindings to
keybindings.json
to bind
ctrl+h/l/j/k
for those situations.

This config might be in conflict with "Quick Window Navigation" above.

keybindings.json

[
    {
        "key": "ctrl+h",
        "command": "list.collapse",
        "when": "listFocus && !inputFocus"
    },
    {
        "key": "ctrl+l",
        "command": "list.expand",
        "when": "listFocus && !inputFocus"
    },
    {
        "key": "ctrl+j",
        "command": "list.focusDown",
        "when": "listFocus && !inputFocus"
    },
    {
        "key": "ctrl+k",
        "command": "list.focusUp",
        "when": "listFocus && !inputFocus"
    }
]

Rebind action menu for file-browser

File browser, which is bound to

 f f
by default, binds
ctrl+a
to open an action menu; however,
ctrl+a
can be used move the text cursor to the front. Your can merge the following example keybindings to
keybindings.json
to use
ctrl+o
instead of
ctrl+a
in the file browser to open an action menu.
keybindings.json

[
    {
        "key": "ctrl+a",
        "command": "-file-browser.actions",
        "when": "inFileBrowser"
    },
    {
        "key": "ctrl+o",
        "command": "file-browser.actions",
        "when": "inFileBrowser"
    }
]

Use non-character keys

See in vscode-which-key

Display menu with a delay

See in vscode-which-key

Known Issues

  • File browser (bound to
     f f
    ) doesn't work correctly when the active document is a local file with VScode Remote (vscode-file-browser/#6)
  • File browser (bound to
     f f
    ) doesn't have a button to open local file with VSCode Remote

Release Notes

See CHANGELOG.md

Contribution

All feature requests and help are welcome. Please open an issue to track.

Credits

Thanks @kahole for his implementation of quick pick menu in edamagit.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.