Allow super granular scope based keybinding #215

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

Comments

Projects
None yet
1 participant
@t9md
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 Mar 31, 2016

@t9md t9md reopened this Apr 2, 2016

t9md added a commit that referenced this issue Apr 2, 2016

#215 set only when pending state.
And use COMMAND_NAME + “-pending” scope name to avoid conflicts

@t9md t9md closed this Apr 2, 2016

@t9md

This comment has been minimized.

Show comment
Hide comment
@t9md

t9md Apr 6, 2016

Owner

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'
Owner

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