Reputation: 5151
I have the strangest problem with a macro created from yanked text. I have an access to another vim installation on Ubuntu (I use Gentoo) and this problem does not occur. What I need is help to find the reason of such a behaviour.
I start recording a macro with, let's say, qr
.
I type exactly the following characters: iasdas<ESC>q
This macro should insert text asdas
and exit insert mode. Running it with @r
does exactly that.
Now I want to manually type my macro, yank it and run.
I enter in insert mode:
iasdas^[
Of course ^[
is inserted with <Ctrl>+v, <ESC>
.
I yank it to a register q
: "qyy
.
Then I verify the content of q
and it's exactly correct.
I run it with @q
and what I get is most confusing. Text asdas
is typed, vim is in insert mode(!) and the cursor is over the last s
.
It means that actually what happened is iasdas^[i
- otherwise the cursor would be after s
. Changing ^[
to jj
, which I have mapped to escape, didn't change anything.
I have an extremely complicated macro which I tried to edit by hand. Now I have to escape insert mode after macro, which is bad in so many ways...
As a workaround I've made a macro which contains @q^[
, but it breaks behaviour of @@
, so it's not a good solution.
This problem gave me a headache. I don't know where to start looking for a reason of this. I have just updated to Vim 7.4, the same behaviour was observed on my 7.3 with the exactly same configuration.
My .vimrc is pretty long with ~10 addons. Trying to remove each one of them is kinda lot of work, so I'd love to have a hint on any other way to trace it.
With suggestion from I've tried to debug, running vim -V100vimlog filename and I get:
...
Calling shell to execute: "(printf "0x%X" $((0x4A307204 +0x4))) >/tmp/vWo43Tm/2 2>&1"
Executing CursorMoved Auto commands for "*"
Executing TextChanged Auto commands for "*"
Executing CursorMoved Auto commands for "*"
Executing CursorMoved Auto commands for "*"
Executing CursorMoved Auto commands for "*"
Executing TextChanged Auto commands for "*"
Executing CursorMoved Auto commands for "*"
Executing CursorMoved Auto commands for "*"
Executing InsertEnter Auto commands for "*"-- INSERT --
...
Don't know why this InsertEnter fires though, can I get a more elaborate output?
Upvotes: 2
Views: 599
Reputation: 5151
Got the culprit.
The problem is with "yy".
Actually, I stated Then I verify the content of q and it's exactly correct.
That not true. yy
copied ^M
at the end of the line.
I've detected it thanks to @IngoKarkat and @Amit answer. Pasting a macro inside a command line showed this: :iasdas^[^M
.
I don't know why it caused entering the insert mode. I don't have such a mapping for enter key, does it mean something else?
Most confusing, but fun to find. Thanks @Amit and @IngoKarkat for your answer, it was a good hint!
Of course, yanking without ^M
solved the case in a way.
Upvotes: 1