Wednesday, October 3, 2007

"." command doesn't work as expected

First of all I have to thank Kamil Dworakowski who notice this behavior and warn me.

Now, what is happen is after a pair completion, if you exit from insert mode and try to do the last command with the "." key in normal mode, Vim will only reinsert the content that you enter inside the pair chars, e.g:

On insert mode type (123 and exit to normal mode. You should have this:

Now move to any other part of text and press "." (without quotes) and you should see this:

What is happen is that a movement key on insert mode (e.g. <Left>, <Right>, <Down> or <Up>) says to Vim that what will be inserted next is to be kept, the rest forget.

To confirm that make a simple test and you'll see:

  • Go to insert mode;
  • Type 124<Left>3;
  • Go to normal mode;
  • Move cursor to other place;
  • Press <.>;

Now only 3 is reinserted!

This behavior is reflected on TownkAutoCompleteChar because it inserts the "close-pair" and right after that it "insert" an extra <Left> char, making the cursor go inside the pair of chars.

If anyone have any idea on how can I workaround this behavior, please send me a comment or an email!


Kamil Dworakowski said...
This comment has been removed by the author.
Kamil Dworakowski said...

How about setting the cursor position explicitly with a function call instead of simulating pressing of the [left] key?

Thiago Alves said...

I have to think on this approach, actually I even know if it will work, but I'll test it. If it works probably I'll have to change the whole "engine" of the solution because right now I return the string to be inserted after an open char and positioning cursor after that depends if the completion happens or not.