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

Feature: only exit a submode explicitly #1

Closed
suy opened this issue Apr 6, 2012 · 8 comments
Closed

Feature: only exit a submode explicitly #1

suy opened this issue Apr 6, 2012 · 8 comments
Labels

Comments

@suy
Copy link

suy commented Apr 6, 2012

Hello.

First, I want to congratulate you for vim-submode and your many other great plugins. I like them a lot! And I've just started trying them.

I've been using vim-submode with great pleasure to navigate the changelist and resize windows, but I've found a case in which it would be great if submodes could only be exited explicitly, so you could operate vim normally, and still have available the shortcuts that one has defined for the submode.

The case is: you are in vimdiff mode, and want to navigate the changes, so you create a submode to avoid having to type the tedious ]c]c]c. But in the middle you want to diffget and diffput, so you map something to do it. But now you realize there is a typo in a line, so you have to exit the mode, fix it, and enter it again to continue inspecting. Is not a big deal at all, but it could be even better if you could exit the submode only after or any other key the user has defined.

I don't know if it's possible or easy to do, but if it serves as an inspiration, there is a plugin named vim-space that does something similar: after some "hook" like ]c, g+ or g; it maps and to provide a sort of "generic next/previous". You operate Vim normally, but you still have those shortcuts available.

I like vim-submode a lot more, though, since is much more powerful and configurable, but I would love if it could have this feature too.

Thank you very much, and seriously, congratulations for your plugins, because some (like this) blew my mind when I first saw them.

@kana
Copy link
Owner

kana commented Apr 6, 2012

Thank you for the feedback. I'll consider it later. But I wrote vim-submode as a proof of concept and it has been 2 or more years since the first commit. So that it might take a long time to load the details of vim-submode into my brain...

@kana
Copy link
Owner

kana commented Apr 7, 2012

The case is: you are in vimdiff mode, and want to navigate the changes, so you create a submode to avoid having to type the tedious ]c]c]c. But in the middle you want to diffget and diffput, so you map something to do it. But now you realize there is a typo in a line, so you have to exit the mode, fix it, and enter it again to continue inspecting. Is not a big deal at all, but it could be even better if you could exit the submode only after or any other key the user has defined.

Did you mean that you don't want timeout in a submode? If so, set g:submode_timeout to 0.

@suy
Copy link
Author

suy commented Apr 7, 2012

In general, I want timeout, but for this kind of submode it probably should be disabled since I would like to exit the submode only explicitly.

Feel free to mark the issue as 'wontfix', since now that I think about more deeply, I understand that is probably changing this plugin too much. I probably should try making vim-space more configurable instead (I like a lot how you can configure vim-submode, and the other plugin doesn't allow to use any other key besides , which I don't like at all).

@kana
Copy link
Owner

kana commented Apr 7, 2012

So, what you want is per-submode timeout, isn't it?

@suy
Copy link
Author

suy commented Apr 7, 2012

That, yes, but also be able to say "for this submode, this key is mapped to that, and all other keys instead of exiting the submode, do what they normally do instead of interrupting the submode".

That way I could make a submode for "diff-mode", and while I'm on that mode, have some shortcuts for navigating through changes with easier keys, but still be able to enter insert mode and fix a typo. When I'm done, I could exit the submode explicitly by pressing the key configured with submode#leave_with().

As I said, maybe it changes too much the way the plugin works, so don't worry at all if you don't want to implement it! The way it is right now is still very helpful.

@kana
Copy link
Owner

kana commented Apr 10, 2012

That, yes, but also be able to say "for this submode, this key is mapped to that, and all other keys instead of exiting the submode, do what they normally do instead of interrupting the submode".

Okay, I've realized that. But it's not possible to implement that fully.

For example, Visual mode can be treated as a submode for Normal mode. Though we can enter Insert mode from Visual mode (<C-v>jjjI etc), we can not return to Visual mode directly from Insert mode. We can only return to Normal mode from Insert mode.

Like this, once we enter to another mode from a submode, we can not return to the submode directly.

That way I could make a submode for "diff-mode", and while I'm on that mode, have some shortcuts for navigating through changes with easier keys, but still be able to enter insert mode and fix a typo. When I'm done, I could exit the submode explicitly by pressing the key configured with submode#leave_with().

If I understand correctly, the workflow you want is as follows?

(1)  ]c       Normal mode
     |        entering to the "diff-mode" submode.
     v
(2)  jjj...   Normal mode (diff-mode)
     |
     v
(3)  cawfoo   Insert mode
     |        to fix a typo.
     v
(4)  <Esc>    Insert mode
     |        leaving from the Insert mode.
     v
(5)  jjj...   Normal mode (diff-mode)
     |
     v
(6)  <Esc>    Normal mode (diff-mode)
              leaving from the "diff-mode" submode.

Currently, c at the step (3) only leaves from the "diff-mode" submode. It's possible to change the c also to enter Insert mode. But it's not possible to directly return to the "diff-mode" submode from Insert mode at the step (4).

Though there might be ways to implement that, they're ad hoc or not generic to support all cases.

@suy
Copy link
Author

suy commented Apr 26, 2012

Hi Kana. You got right the workflow I suggested.

I've been giving this some thought, and you are right, it's probably too complex what I suggested, and might not fully make sense. Thanks for considering it, and feel free to close the issue.

@t9md
Copy link

t9md commented Oct 16, 2013

Just a comment. Suy, I myself want 'view-only' mode which map some basic 'f,b,u,d' keys to <C-f>, <C-b> and so on.
Its very alpha state but might useful for you.
https://github.com/t9md/vim-mapswap

@kana kana added the wontfix label Feb 10, 2014
@kana kana closed this as completed Feb 10, 2014
This was referenced Feb 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants