Reputation: 3172
In all honesty the title is bad. Consider the following 5 lines:
function Example()
let @@ = "-_-"
execute "normal! ]P"
call cursor(line('.'), col('.')-1)
endfunction
When this function is called, I expect to get -_-
as output and the cursor should be moved to the left, meaning that it is at the third character, so if I press a key, like I for example I will get -_i-
What happens in reality is quite different (and to some degree interesting)
The output the first time this is called is - _-
and after that it's _--
I assume that "cursor" shifts the position of the word under the cursor. Basically: Why is it happening? How can I get the desired effect ?
Very important edit: Apperantly the problem isn't in the plugins. When I go for:
call Example()
It works flawlessly. Thing is it is supposed to be triggered by a key. I have currently bound it like so:
inoremap ' <C-O>: call Example()<CR>
So now I am thinking that something in the mapping is broken...
Upvotes: 1
Views: 72
Reputation: 172510
----_-_-_-_-
on repeated invocations, as expected. I again suspect there are plugins at work. Try with vim -N -u NONE
. As this is a paste, there's little that could influence this function, though. You could try to workaround via :noautocmd call Example()
, but I'd rather try to find the root cause of this disconcerting strangeness.]P
(paste with adapted indent) has no effect here. You could just as well have used P
.:normal! h
. The subtraction from col('.')
again only works for single-byte ASCII characters.Upvotes: 1