I'm trying to grok the change list on vim and I'm having trouble understanding the following behavior:
As example I insert the following text:
I like chips and fish.
Realized I got the nouns in the wrong order, so I want to get:
I like fish and chips.
Starting with a fresh vim instance with no .vimrc (vim -u NONE
) this is exactly what I do (# are just for explanation):
iI like chips and fish.<Esc> # Insert text. Realize I want to switch the words
Fc # Jump back to 'chips'
de # Delete the word (and put it in anon register)
ff # Jump to the 'fish' word
vep # Select the word, and paste from anon register
g; # Try to jump back to the position where I change
# the word 'chips'. It doesn't work and I get:
E19: Mark has invalid line number
# To see what is going on i print the change list:
:changes
change line col text
2 1 12 I like and chips.
1 2 12 -invalid-
>
My first question is why the jump didn't work in the first place?
Second, the -invalid-
entry of the change list doesn't make any sense to me. As you saw I never went beyond line 1. Why is an entry with line 2?
Im using Vim 7.4.52
Update: The -invalid- seems to be a bug. I already reported it:
In the default Vim on Mac OS X (7.3 Normal version without GUI, no patches),
g;
moves the cursor to thec
inchips
and the output of:changes
is different from yours:The fact that only one change is remembered is consistent with this paragraph from
:help g;
so everything is normal (if a bit surprising).
With a reasonably recent MacVim (7.4.258), I get the behavior you describe for
g;
and a slightly different:changes
output ("fish" is missing in yours):It smells a lot like you discovered a bug and I strongly suggest you notify the vim_dev mailing list about it (if they are not already aware).