Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Sync insert mode across tabs

Open jeffwillette opened this issue 8 years ago • 14 comments

Please thumbs-up 👍 this issue if it personally affects you! You can do this by clicking on the emoji-face on the top right of this post. Issues with more thumbs-up will be prioritized.


What did you do?

Have two tabs open one in insert mode and one in normal mode, move to the other tab

What did you expect to happen?

The cursor to remain in the current mode

What happened instead?

The tab that was entered remembered its own cursor state

Technical details:

  • VSCode Version: 1.10.2
  • VsCodeVim Version: latest
  • OS: osSierra

I find myself making mistakes A LOT because of this...

In vanilla vim it is not possible to switch tabs without being in normal mode..In gvim if you change the cursor state and then click on a tab, the current cursor state will follow to the new tab regardless of the old state within the tab.

Since VSCode most resembles gvim, and one can click on a new tab to change it, I believe the cursor state should follow into the new tab. Is this possible with VSCode?

jeffwillette avatar Mar 28 '17 04:03 jeffwillette

What happens in gvim if you go into insert mode in 1 split, then click on the other split?

johnfn avatar Mar 28 '17 04:03 johnfn

Oops sorry you answered that. Very interesting.

johnfn avatar Mar 28 '17 04:03 johnfn

I find that with the current behavior of vscodevim, I always have 4-5 tabs open and when moving fast, I don't think about cursor state and it always seems to slow me down and interrupts my thought process having to consciously switch back when an error occurs

jeffwillette avatar Mar 28 '17 07:03 jeffwillette

Yeah, I personally never leave a tab in anything except normal mode. It's the whole "get in and out of insert mode quick" vim ethos thing. But I can understand you running into issues here.

My Vim actually appears to only maintain if you're in insert mode when switching between splits. If I go into, say, Visual mode, and then click to the other split, I'm now back in Normal mode.

johnfn avatar Mar 28 '17 07:03 johnfn

I'm having issues with this as well. If I move between splits - the "mode" is preserved. As long as I move/switch to another tab - I'm always back to Normal mode.

Maybe there should be a setting about this?

StanBright avatar Apr 26 '17 01:04 StanBright

I think it is probably an issue with the API that handles VScode, I will try to look into it soon if I have time, but I do not have any experience with VScode so IDK what I am doing

jeffwillette avatar Apr 28 '17 01:04 jeffwillette

This is by design - each VimState (which is per-editor) has a mode independent of others.

J-Fields avatar Aug 05 '19 05:08 J-Fields

It’s been too long for me to remember why I watched this issue. But I think maybe set each VimState to the same should be more easy for continuously switching tabs and prevent unexpectedly inserting letters at random places?

escape0707 avatar Aug 05 '19 05:08 escape0707

The way as it is right now is inconsistent with Vim behaviour. In addition to that, it is simply inconvenient when one is often switching between tabs and end up with inputting lots of j, k etc... Please, consider fixing this.

osenvosem avatar Jul 20 '20 09:07 osenvosem

I use [ and ] to navigate tabs left/right and if I ctrl+p while in insert mode and I try to move two tabs over using ]], I end up inserting ] into the tab that was left in insert mode. Are there any workarounds for this? Such as always exiting insert mode when a tab loses focus?

xaviergmail avatar Nov 12 '20 05:11 xaviergmail

@xaviergmail Why not make a keybinding that exits insert mode then goes to the next tab?

J-Fields avatar Nov 12 '20 18:11 J-Fields

@xaviergmail Why not make a keybinding that exits insert mode then goes to the next tab?

Because the issue also happens when a text editor loses focus from things like Ctrl+P or even just using the mouse.

I'm not comfortable enough to make a PR for this kind of behavior but I have made an extension that simply runs the extension.vim_escape command when the currently active editor changes: https://marketplace.visualstudio.com/items?itemName=xavbergeron.vim-leave-insertmode

This extension solves the issue @osenvosem and others including myself seem to have of accidentally inserting text into unsuspecting buffers when using vim keybindings to switch editors

xaviergmail avatar Dec 08 '20 21:12 xaviergmail

Imo, it's rather unfortunate that people have to make and install extensions to correct the behavior of other extensions. Ideally, the vim extension would always keep the mode consistent across tabs (reasoning that mode is a property of the editor, not the file being edited). Barring that, it ought to be a setting that the user can control. Alas, I have no experience in this area or I'd try to PR it myself.

gorsat avatar Feb 03 '23 16:02 gorsat

bump

natohutch avatar May 09 '24 11:05 natohutch