Vim mode dot command does not correctly repeat text in parenthesis/square brackets


#1

Using c9’s vim mode. If I have some code:
u.firstname==u.lastname

then I change the line to:
ul[0].firstname==u.lastname

I would expect to be able to place the cursor after the second u and use the dot command to get:
ul[0].firstname==ul[0].lastname

but instead it produces this:
ul[0].firstname==ul[]0.lastname

The second 0 is outside of the square brackets. The same issue happens with parenthesis.


#2

Thank you for detailed report.
Should . retype the same text, or insert exactly same as the first time?
That can result in different behavior because [ autopairing depends on what character is next.


#3

I see your point about autocomplete but I am not sure I understand your question perfectly.

My understanding of real Vim’s behavior is that the dot command actually repeats the keystrokes because of Vim’s modal system. Generally, this means the dot command produces the same result as during the original text edit because it is the exact same to Vim.

There are a number of autopairing plugins for Vim. Most of them seem to handle this as expected. i.e. the digit appears inside the autopaired characters. There might be some special rules or programming within these plugins to produce this but I haven’t looked specifically.

Does that answer your question?


#4

Not quite.
I can change current buggy behavior to either always insert the exact text as in the first time, or emulate typing character by character.
When typing character by character, your example would work correctly ul[0].firstname==ul[0].lastname but for ul[0].firstname==ulastname it would produce ul[0].firstname==ul[0lastname since autopairing depends on the surrounding text.
In this case typing seems to produce undesirable result, but in another case, when inserting a new line, inserting exact text breaks autoindentation:

split>here
split>
here

after recording the above edit, and repeating it on

    split>here

it becomes

    split>
here

instead of

    split>
    here

#5

I think I see what you mean.

From my perspective, if we have to choose, I would prefer my description where inserting bracket type text works. If indenting breaks, it’s only one Enter keypress instead of a potentially large text edit where the dot command shines.

I’m not familiar enough with c9’s Vim emulation to know what other side effects this might cause.