Swapping "i" and "e" causes "ds" and "cs" to stop working
Hi, I found myself using "i" much more than "e" and on dvorak layout the key "e" is more convenient than the key "i", so I swapped the two keys like this: (define-key evil-normal-state-map "i" nil) (define-key evil-normal-state-map "I" nil) (define-key evil-visual-state-map "I" nil) (define-key evil-motion-state-map "e" nil) (define-key evil-motion-state-map "E" nil) (define-key evil-motion-state-map "i" 'evil-forward-word-end) (define-key evil-motion-state-map "I" 'evil-forward-WORD-end) (define-key evil-normal-state-map "e" 'evil-insert) (define-key evil-normal-state-map "E" 'evil-insert-line) (define-key evil-visual-state-map "E" 'evil-insert) However, after doing this, the "ds" and "cs" in "surround" no longer work. I don't understand why this is happenning and whether this is evil's problem or this is a problem is in "surround", or, if I'm doing something wrong. Thanks, York
On 2011-08-31 20:07 +0200, York Zhao wrote:
(define-key evil-motion-state-map "i" 'evil-forward-word-end)
This overwrites the bindings for inner text objects, which are bound in `evil-motion-state-map' as "iw", "i(", etc. Evil and evil-surround can be made more flexible in two steps: 1. Define the keymaps `evil-outer-text-objects-map' and `evil-inner-text-objects-map' for binding text objects, and have evil-surround use these maps. Evil commit 2104311 adds the keymaps, and I have created a pull request for evil-surround: https://github.com/timcharper/evil-surround/pulls 2. With the above in place, it might be more fitting to move text objects from Motion state to Visual state and Operator-Pending state (instead of having the latter two inherit from the former). Text objects have no function in modes that come up in Motion state, and as seen, they get in the way of rebinding. -- Vegard
(define-key evil-motion-state-map "i" 'evil-forward-word-end)
This overwrites the bindings for inner text objects, which are bound in `evil-motion-state-map' as "iw", "i(", etc.
I had actually figured this out by myself last night and did a quick fix by using an advice on `surround-inner-overlay' function. But your changes are the ultimate solution and again it was nicely designed and simplified my customization a lot. Thank you very much.
2. With the above in place, it might be more fitting to move text objects from Motion state to Visual state and Operator-Pending state (instead of having the latter two inherit from the former). Text objects have no function in modes that come up in Motion state, and as seen, they get in the way of rebinding.
It might be a good idea but is it going to cause all the modes in evil-motion-state to lose the ability to use texe objects? York
On Sep 1, 2011, at 6:18 AM, Vegard Øye wrote:
On 2011-08-31 20:07 +0200, York Zhao wrote:
(define-key evil-motion-state-map "i" 'evil-forward-word-end)
This overwrites the bindings for inner text objects, which are bound in `evil-motion-state-map' as "iw", "i(", etc.
Evil and evil-surround can be made more flexible in two steps:
1. Define the keymaps `evil-outer-text-objects-map' and `evil-inner-text-objects-map' for binding text objects, and have evil-surround use these maps. Evil commit 2104311 adds the keymaps, and I have created a pull request for evil-surround:
https://github.com/timcharper/evil-surround/pulls
2. With the above in place, it might be more fitting to move text objects from Motion state to Visual state and Operator-Pending state (instead of having the latter two inherit from the former). Text objects have no function in modes that come up in Motion state, and as seen, they get in the way of rebinding.
-- Vegard
Sorry I didn't get to that pull request earlier. I didn't know what was motivating it, nor who epsilon47 was. Merged in, thanks! Tim
On 2011-09-01 18:38 +0200, York Zhao wrote:
On 2011-09-01 14:18 +0200, Vegard Øye wrote:
With the above in place, it might be more fitting to move text objects from Motion state to Visual state and Operator-Pending state (instead of having the latter two inherit from the former).
It might be a good idea but is it going to cause all the modes in evil-motion-state to lose the ability to use texe objects?
And this has been done in commit 4210051. No, it won't lose anything because text objects have no function in Motion state /per se/. What you probably want to do (and this is still possible) is to create a Visual selection in a buffer that came up in Motion state (e.g., "viwiw"). But this calls the text object ("iw") in Visual state, not Motion state; if you were to call a text object in Motion state, nothing would happen. The only reason text objects were bound in `evil-motion-state-map' was so that Visual state and Operator-Pending state could inherit the bindings from that keymap. Now that text objects bindings have their own keymaps, this is no longer necessary. -- Vegard
With the above in place, it might be more fitting to move text objects from Motion state to Visual state and Operator-Pending state (instead of having the latter two inherit from the former).
It might be a good idea but is it going to cause all the modes in evil-motion-state to lose the ability to use texe objects?
And this has been done in commit 4210051.
No, it won't lose anything because text objects have no function in Motion state /per se/. What you probably want to do (and this is still possible) is to create a Visual selection in a buffer that came up in Motion state (e.g., "viwiw"). But this calls the text object ("iw") in Visual state, not Motion state; if you were to call a text object in Motion state, nothing would happen.
The only reason text objects were bound in `evil-motion-state-map' was so that Visual state and Operator-Pending state could inherit the bindings from that keymap. Now that text objects bindings have their own keymaps, this is no longer necessary.
Thanks for the explanation.
participants (3)
-
Timothy Harper -
Vegard Øye -
York Zhao