Skip to content

Allow super granular scope based keybinding #215

Closed
@t9md

Description

@t9md

This is experiment but idea is very simple.

Atom provides scope based keybinding.
To create scope, just set css class for editorElement.
So

Create very short life time scope to when specific operator is running.

  • e. g. keymap only activated only while waiting for target motion/text-object for yank.

Here, following keymap is only mapped only when Yank, or Delete operation is waiting for tareget.
So you can yank or delete paragraph by yp, dp, shorter than yip, dip.

But other operator-pending-mode keybinding is not contaminated by this keymap.
This is the direct advantage of this granular narrowed keymap scope.

'atom-text-editor.vim-mode-plus.yank, atom-text-editor.vim-mode-plus.delete':
  'p': 'vim-mode-plus:inner-paragraph'

The change is just set css class while operation start running, then remove this css class on operation finished.

CSS class to be set is comand name without vim-mode-plus prefix.
So for vim-mode-plus:yank command, yank is scope to be set.

CSS class to be set is "command name without vim-mode-plus prefix" + "-pending".
So for vim-mode-plus:yank command, scope should be yank-pending.
This class is set only when command was not complete like target requiring operator(d, y) or input requiring motion(m, /).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions