Re: i_CTRL-O side-effects
- Ross Presser wrote:
> Slightly related to this: If I am in insert mode and type ^O60a-[ESC], I endHere is another way:
> up in normal mode rather than returning to insert mode. I think I see why -
> the a put me back in insert mode, and the ESC took me out of it, and ^O
> didn't put me back in. Can anyone confirm this? Is this expected behavior?
> If it is expected, is there a better way to do what I want - i.e. insert 60
> dashes then continue typing?
<C-O> Enter Insert-Normal mode.
60 Give the count.
"= Specify the Expression Register.
'-' Literal string. (I could have used "-" instead, but I thought
that "="-" would be confusing.)
<CR> Enter the value for the Expression Register.
You can also use (starting from Insert mode, as above)
using the following function (which will be in foo.vim the next time I
function! RepeatString(count, ...)
" Initialize str to a:1, default to "-" .
let str = (a:0 ? a:1 : "-")
let len = strlen(str)
while len < a:count
let str = str . str
let len = len + len
return strpart(str, 0, a:count)
HTH --Benji Fisher