Wednesday, April 7, 2010

Re: How to remember end of line when quitting/reopening in insert mode

On April 6, 7:24 pm, Andy Wokula <anw...@yahoo.de> wrote:
>> Hi Andy,
>>
>> Finally, just replacing "BufReadPost" with "BufWinEnter" in the latest
>> version of your plugin and suppressing the original BufReadPost
>> autocmd of vimrc_example.vim (if any) does the job.

>Ok.

>> With this plugin+replacement of<C-O> with<C-\><C-O>+ Christian's
>> patch for the menus (not yet tested by myself), one can consider that
>> the proposed problem is completely solved.

>I also looked into it again ...

>I suppose you exclusively switched buffers this way (using the menus, while staying in Insert mode)?

>It's a little bit funny, but it only works because of a bug (that is:
>the variable g:lastpos_startinsert is not removed after "usage", the script expects Insert mode to be started all the time, >which is true for your use case).

>But once you press Escape and continue with Normal mode, it will no longer work.


>The fix: remove the variable after usage.

>But this doesn't work as well: In the above use case (Insert mode on all the time (basically)), the BufWinEnter event >needs announcement of the Insert-mode-is-about-to-start-soon situation.

>I think the only way to solve this is to detect that we are in the Normal-mode-only-for-one-command mode (when >BufWinEnter fires). But such a check is not available yet (AFAIK). And I don't want to suggest this -- it would actually >make the Vimscript-approach superfluous.

>> Bram does not seem enthusiastic to take all that into account
>> officially.

>Once more it turns out that Bram is right. He seems to have some magical feeling what can be done at what not.

>> Perhaps we could reiterate our proposition after intense use has shown
>> no side-effects.

>Sorry, problems found ...

>> Have nice holidays!

>Thanks, Easter holidays.

Hi Andy,
Your script with "BufWinEnter" replacing "BufReadPost" works in insert
mode when switching between buffers is done using <C-\><C-O>:bp<CR>.
It does not work using the menus (without Christian's patch).
If CTRL-L is used to quit insert mode, it no longer works at all,
cursor on column 1 (you are right).

So, 2 solutions:
1) Keep your (bugged) script and work in insert mode only
2) Keep the original vimrc_example.vim with "BufReadPost" replaced
with "BufWinEnter". It works in normal mode and almost works in insert
mode. I still have to understand why the vimrc_example's BufWinEnter
autocmd works in normal mode when switching between buffers when the
similar in your script does not.

Best regards
Jean Johner


--
You received this message from the "vim_use" 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

To unsubscribe, reply using "remove me" as the subject.

No comments: