1

Re: switching file should set viemu in normal mode

In my opinion, if you are in insert mode and switch file the logical thing to do is to switch to normal mode. Not stay in insert mode.

This is how vim works.  Or at least I don't think it's possible to switch buffer without going to normal mode first. It makes plenty sense to be in normal mode when you switch file since the first thing you want to do is probably not to edit where the cursor happens to position itself in the newly opened file.

2

Re: switching file should set viemu in normal mode

Hi Mopi,

This is a common misconception, as vim actually does not work that way. The main reason it *seems* that vim works like that and ViEmu works wrong is that, in vim, you can rarely switch buffers without going into normal mode.

On one hand, in vim, if you open two windows on different buffers, enter insert mode, and click the mouse to move to the other window, it stays in insert mode. But since you can't do a :bn or similar in insert mode, and you rarely use the mouse, it happens very infrequently.

On the other hand, given VS has it's own keybindings that are transparent to ViEmu (like Ctrl-Tab to go to the next buffer), and given that the mouse is used more often to move to other tabs or windows, it's more frequent that you expect to be in normal mode and find yourself in insert mode.

You are right in asking for different behavior though, given the circumstances. I think the right solution would be to add a hook to buffer changes and add a user setting to reset to normal mode in this case. This would seem more like vim and be more natural in many case.

This is pending for a future version, hopefully for ViEmu 3.0 where I plan to add scripting support and advanced scripting hooks.

3

Re: switching file should set viemu in normal mode

I think, perhaps, it might be even better if each buffer had its own state (with the default upon opening a file being normal mode) and when you switch buffers you return to the state (mode) you were in when you left.  Then, if you were in input mode and popped over to another buffer for a bit to check on something when you came back it would be as if you had never left.  The only downside I can think of, off the top of my head, is that any macros which included switching buffers (presuming it is even possible to write a macro which switches buffers) would have to find some way to force the other buffer into whatever mode it required since it would have no way of knowing its current mode.

- Les

4

Re: switching file should set viemu in normal mode

Indeed, both VS and ViEmu macros can switch buffers. Hopefully the scripting engine I plan to implement will allow to store per-buffer info, and it will be easy to configure such function as remembering the mode through simple buffer-focus hooks.

When this issue was discussed (I think on these very forums) a couple of years ago, some people liked one type of behavior, while others liked a different type of behavior. More and more, I reach the conclusion that the next step of ViEmu has to be full configurability using scripting. That should allow everyone to configure it to their own taste.

Thanks for the detailed feedback!

  - Jon

5

Re: switching file should set viemu in normal mode

+1