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

Allow super granular scope based keybinding #215

Closed
t9md opened this issue Mar 31, 2016 · 1 comment
Closed

Allow super granular scope based keybinding #215

t9md opened this issue Mar 31, 2016 · 1 comment

Comments

@t9md
Copy link
Owner

t9md commented Mar 31, 2016

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, /).

@t9md t9md closed this as completed Mar 31, 2016
@t9md t9md reopened this Apr 2, 2016
t9md added a commit that referenced this issue Apr 2, 2016
And use COMMAND_NAME + “-pending” scope name to avoid conflicts
@t9md t9md closed this as completed Apr 2, 2016
@t9md
Copy link
Owner Author

t9md commented Apr 6, 2016

Here is my example.

  • yank/delete paragraph by yp, dp
  • yank/delete commented area by y/, d/
  • uncomment consecutive commented area by g//(g/ is mapped to toggle-line-comments operator)
  • toggle comment for this paragraph by g/p
'atom-text-editor.vim-mode-plus.yank-pending, atom-text-editor.vim-mode-plus.delete-pending':
  'p': 'vim-mode-plus:inner-paragraph'
  '/': 'vim-mode-plus:inner-comment'

'atom-text-editor.vim-mode-plus.toggle-line-comments-pending':
  '/': 'vim-mode-plus:inner-comment'
  'p': 'vim-mode-plus:inner-paragraph'

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

No branches or pull requests

1 participant