Discussion:
buffer local mode?
(too old to reply)
Guido Van Hoecke
2008-08-18 13:48:02 UTC
Permalink
Hi,

Is it possible to configure vim so that insert/normal mode is by default
buffer local? When having several files open either in split windows or
tabs, and switching between these, I'd like each buffer to retain its
previous insert on normal mode status. Right now, when switching to an other
buffer from a buffer in insert mode, the new buffer is also in insert mode,
rather than its previous state. Is it possible to change this behaviour?

TIA,

Guido

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Tony Mechelynck
2008-08-19 00:48:40 UTC
Permalink
Post by Guido Van Hoecke
Hi,
Is it possible to configure vim so that insert/normal mode is by default
buffer local? When having several files open either in split windows or
tabs, and switching between these, I'd like each buffer to retain its
previous insert on normal mode status. Right now, when switching to an
other buffer from a buffer in insert mode, the new buffer is also in
insert mode, rather than its previous state. Is it possible to change
this behaviour?
TIA,
Guido
I think the game isn't worth the candle. You would have to remember the
state in a buffer-local variable at the BufLeave event, and restore it
if the variable exists at the BufEnter event. If the variable does not
exist, it is not an error: it can e.g. happen when entering a buffer for
the first time after loading the file.

However you might have to do fancy footwork to remember Insert mode, see
the note at the bottom of ":help mode()".

See:
:help mode()
:help :autocmd
:help BufLeave
:help BufEnter
and perhaps
:help InsertEnter
:help InsertLeave
:help InsertChange
:help 'statusline'
:help :function


Best regards,
Tony.
--
Fine day to throw a party. Throw him as far as you can.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Loading...