Sunday, March 25, 2012

buggy behavior when changing 'virtualedit' inside scripts?

Hi,

Consider this line of text: "abc def". If the cursor is on "d" and
you type "Dix<esc>" in normal mode, the result will depend on the
value of 'virtualedit'.

* when ve="", you get "abcx "
* when ve="onemore", you get "abc x"
* when ve="all", you get "abc x"

You will find that you get the same results if you define this
function and call it:

function Foo()
execute "normal! Dix\e"
endfunction

Now consider these two variations:

function Foo1()
set ve=onemore
execute "normal! Dix\e"
endfunction

function Foo2()
set ve=all
execute "normal! Dix\e"
endfunction

If you begin with ve="" and try calling these functions, you will be surprised:

* with Foo1, you get "abc x"
* with Foo2, you get "abcx "

This really threw me for a loop -- it took me forever to figure out
why my script wasn't working this morning. Is this behavior
intentional or should I submit a bug?

- Aaron

--
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

No comments:

Post a Comment