Maybe this is intentional, but I find no mention of it in the help.

I was answering this stackoverflow post for fun, and discovered some
surprising behavior of startinsert and friends:
http://stackoverflow.com/questions/22389934/how-can-i-keep-modes-local-to-a-tab

I ended up with the following code:

    augroup TAB_MODES
      au!
      autocmd TabLeave * let t:lastmode = mode(1)
      autocmd TabEnter * if !exists('t:lastmode') | let t:lastmode = 'n' | endif
      autocmd TabEnter * if t:lastmode ==# 'n'  | stopinsert    | endif
      autocmd TabEnter * if t:lastmode ==# 'i'  | startinsert   | endif
      autocmd TabEnter * if t:lastmode ==# 'R'  | startreplace  | endif
      autocmd TabEnter * if t:lastmode ==# 'Rv' | startgreplace | endif
    augroup END

The problem is, that executing "startinsert" while in replace mode
doesn't seem to do anything. "startreplace" when in insert mode
likewise has no effect, and the same for "startgreplace".

Using "stopinsert | startinsert" doesn't work either; the editor just
seems to ignore the startinsert altogether if I do that, leaving it in
normal mode always.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui