When I use most commands, they take effect instantly. When I use the O command, however, I see the "O" replace the current character for a about a second, then the current character returns, and a new line is inserted and opened.

I have no such problem with the o command (open a new line below and insert).

If it makes a difference, I'm using vim from bash, in the Gnome Terminal on Ubuntu 10.04.

link|improve this question

feedback

2 Answers

up vote 9 down vote accepted

If the previous key pressed was ESC, this is because there are keys that can generate escape sequences beginning with ESC O. For example depending on the cursor key mode, the up arrow key may generate the escape sequence ESC O A.

If it sees a partial escape sequence, vim will wait for a short timeout to see if another character is received that matches one of the escape sequences defined for your terminal type. If not it will treat the characters as separate keystrokes. You can test this by entering a capital A while waiting for the line to open to see if it treats it as an up arrow instead.

There are some vim settings that can be used to control this. :set ttimeoutlen=100 will change the escape sequence timeout to 100ms. :set noesckeys will completely disable recognition of keys sending an escape sequence when in insert mode. Also, vi-compatible mode will not have this issue because esckeys is off in that mode – that is why vim -u NONE works.

link|improve this answer
Just to clarify, my "experiment" with the 140k line file was in full vim mode with my standard complement of of plug-ins and filetypes. I can see where you might have concluded that I'd used -u NONE but we still lack confirmation from the OP. – msw Jul 8 '10 at 7:49
wow! that was mildly irritating for a while but I've never thought about it. makes perfect sense now. Esc O A indeed works just like up-arrow. – Vitaly Kushner Aug 30 '10 at 3:17
feedback

Given how many bits of code might execute given auto-indent, syntax highlighting and such, it may well be that the task of opening a line above is very expensive. Try

$ vim -u NONE filename

where NONE is literal, to cause vim to skip all initialization files and see if the problem still happens. I'll be surprised if the delay remains.

Just for kicks, I ran vim against a 140k line, 10MiB file and Opened a line near the end, the delay was imperceptible.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.