syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.67k stars 4.89k forks source link

Nested escape states? #849

Closed jasonkuhrt closed 9 years ago

jasonkuhrt commented 9 years ago

When doing spc s R e we enter a mode that is editing all instances of a word as found under the cursor. To begin editing I may do e.g. c e only to have to esc jk after because I didn't edit the text exactly the way I wanted to. But when I do escape it exits me out of both:

I wonder if this is something that would just be frustrating to newbs or if there is a genuine feature needed that allows a full stack of modes to be escapes vs a pop-escape trigger that only escapes the immediate mode...

syl20bnr commented 9 years ago

I guess jk is evil-escape ? This is the expected behavior then. ESC in iedit-insert state will go back to iedit state. The documentation is more comprehensive in the iedit-lisp-state readme (but is evil-escape agnostic): https://github.com/syl20bnr/evil-iedit-state#state-transitions

jasonkuhrt commented 9 years ago

I guess jk is evil-escape

Yes

This is the expected behavior then. ESC in iedit-insert state will go back to iedit state

You mean --INSERT MODE-- --> --NORMAL MODE--?

So what I'm wondering is if we should support/invent this:

`spc s R` // Enter symbol-highlight-mode
`c e`     // Enter insert mode
`ESC`     // Exit insert mode (back to symbol-highlight-mode)
`ESC`     // Exit symbol-highlight-mode (back to normal mode)
syl20bnr commented 9 years ago

I see you enter the iedit state from auto-highlight-symbol. There are 3 ways to enter the iedit state:

Now I think you noticed that iedit is composed of 2 states:

When in iedit insert:

Also don't forget that in iedit state you can navigate easily between the occurrences with n and N and also change the scope of the edition to the function with F, the line with L and even incrementally above or bellow current point with J and K.

My advice is to use directly SPC s e (which will select the symbol under point like auto-highlight-symbol) and change the scope in iedit.

jasonkuhrt commented 9 years ago

Thanks for this great info it really helps. Maybe roll some of this into docs somewhere some day.

I'm glad to hear there is incremental ESC, that's great! My question is then why doesn't jk map to ESC here? That's really a shame I think? Why can't we make evil-escape work incrementally too. Its completely (seemingly, to me) the right thing to do. I see no value in complicating life with "different mental models for escape".

syl20bnr commented 9 years ago

It's very hard to get the right behavior, when evil-iedit-state was developed some users reported that it was annoying that pressing fd (jk) always returned to normal state except in iedit insert. They always get trapped in iedit state thinking that fd put them back in normal state. I also think that evil-escape is meant to escape to normal state (it may be even in the description of the package) and I'm pretty sure that if I make an exception for iedit insert a lot of users will be surprised.

I think that it is less damaging to press fd and go back to normal state where it is possible to SPC s e again than staying in iedit and doing some weird stuff on all the occurrences.

syl20bnr commented 9 years ago

I consider this question answered. Feel free to reopen it if you think it should not be closed.