haberdashPI / vscode-modal-keys

Customizable modal editing (ala vim and kakoune)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modal Keybindings in VS Code

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Project Documentation Project Documentation

ModalKeys is an extension for defining modal keybindings in VSCode. Vim is probably the most well known modal editor and ModalKeys includes presets that resemble Vim.

visual display of vim keybindings

The above is a screenshot of the visual documentation feature of this extension; you can access this feature using the command ModalKeys: Toggle keymap documentation, or ModalKeys: Show keymap documentation. It documents the current effect of pressing any given key in the current keymode; the display will update as needed for multi-key commands.

The advantages of modal bindings are the rapid, speed-of-thought manipulations you can perform on text with a well-designed keymap and sufficient practice.

The advantages of using ModalKeys specifically include:

  1. Visual documentation of all keybindings
  2. Seamless integration with the existing features and extensions of VSCode
  3. Complete customization. While you can emulate many of the features of other modal editors like Vim or Kakoune, you will get the most out of ModalKeys by creating your own keymap or modifying an existing one (e.g. starting with one of the presets)

To start creating a custom set of keybindings for ModalKeys, you have a few options:

  1. Read the Tutorial
  2. Start with an example from presets, using the export and import commands to create and then use your own version of the presets.
  3. Read through the Documentation

The general phillosphy of ModalKeys is to leverage existing functionality and behavior already available from VSCode and its extensions, and make it easy to define modal key bindings for these behaviors. If you don't care to integrate behavior from across VSCode and its extensions, you probably just want to replicate an existing modal editor in VSCode; in this case you may want to consider using VSCodeVim, vscode-neovim, or Dance.

Acknowledgements

ModalKeys is a fork of ModalEdit; I am in debt to the hard and thoughtful work from that extension along with its meticulous documentation. There are many important features that differ between the two extensions.

What follows are are just some of the features ModalKeys has which ModalEdit lacks.

  1. Concise keymap format: I've created a terser, simplified keymap format
  2. Visual documentation: you can fill out ::doc:: entries and these will populate a visual keymap documenting your keybindings
  3. Customized modes: You can define your own key modes, to expand the keymap more easily
  4. Search term highlighting: ModalKeys highlights search terms by default (there is an open PR in ModalEdit)
  5. Search with regex: The search command can optionally use regex expressions
  6. Kakoune-like 'repeat-selection': ModalKeys provides a repeatLastUsedSelection command to make kakoune noun-verb workflows repeatable (in contrast with vim's verb-noun workflows)
  7. Keyboard macros

ModalKeys is missing a few features I did not want to maintain from ModalEdit: bookmarks and quick snippets. I find these features to be well covered by several existing extensions in VSCode.

About

Customizable modal editing (ala vim and kakoune)

License:Other


Languages

Language:JavaScript 54.5%Language:TypeScript 43.3%Language:CSS 2.2%