On Sun, Oct 18, 2009 at 8:12 PM, Israel Chauca F. <[email protected]>wrote:

>
> On Oct 18, 3:13 pm, Chris Suter <[email protected]> wrote:
> > Could be something weird about your terminal's left arrow control
> > sequence (what vim sees when you type <left>). Try instead :inoremap (
> > ()<ESC>i which will tell vim to leave insert mode -- leaving the
> > cursor over the ")" -- and then re-enter insert mode. See? The arrow
> > keys are bad for the vim user, even in mappings and scripts!
>
> I actually use :inoremap for the mappings, sorry for the mislead. What
> you recommend as replacement of the arrow keys still brakes the use of
> the '.' command though.
>
> Thanks,
> Israel
> >
>
Ok yeah that makes sense actually. Guess I wasn't thinking things through
completely earlier. Why this would be the case with the inclusion of the
<Left> in the mapping, I don't know -- as my joke about arrow keys may have
suggested, I don't make much use of them. However, regarding the mapping I
gave, this is actually the appropriate behavior -- "." repeats the most
recent edit, and despite the fact that the mapping appears to execute
atomically, the last edit involved is whatever is entered after the "(" is
pressed (which is followed by insertion of ")", exiting insert mode [which
ends that edit], re-entry into insert mode [which begins a new edit: the
last one] and insertion of whatever text goes in the parens). So when you
hit "." the last-entered text is inserted at the current cursor position,
quite properly.

I don't see any immediate way of doing this -- it seems that any way of
getting the cursor back in the middle of the parens requires leaving insert
mode and thus ending the edit. Is there a particular use case you have in
mind that might be solvable another way? It seems like a relatively
infrequent need (repeating the same parenthetical insertion), so maybe it
could be solved without a modification to the mapping. It might be handy to
know that, having inserted such text, you can use ya( to yank the
parenthetical text and then use p or P to place it as needed. This is a
general feature which you can learn more about from :help objects

HTH

-- 
Christopher Suter
www.grooveshark.com

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to