On Tue, 20 Feb 2007 at 9:13am, Tim Chase wrote:

> >> I'm trying to find a good way to remap control+U in insert-mode
> >> so that it begins an undo-block.  There are times when type
> >> control+U in insert-mode and it doesn't do what I intend, or I
> >> want to undo it, only to find that an "u"ndo doesn't solve the
> >> problem.  I know that transitioning out of insert-mode (via <esc>
> >> or <c-o>) will mark a point in the undo-stack.
>  >
>  > I am not sure I understand you right, but do you mean something
>  > like <c-g>u in insert mode ? (:help i_CTRL-G_u):
>  >
>  >        :imap <c-u> <c-g>u
>
> Yes, precisely!  Thanks!  Or rather, it's the piece I was missing:
>
>       :inoremap <c-u> <c-g>u<c-u>
>
> As usual, Vim had the functionality, I just couldn't figure out
> how to find it in the help.  It didn't help that the help only
> provides the one line you quote for the entirety of assistance on
> the matter.  The whole i_CTRL-G family of commands are new to me.
>   More stuff to learn. ;)

I had the same requirement may be about 6 years ago and had to write a
small plugin to do this job. I was essentially mapping the ^U and ^W
commands to first save what is going to be deleted and map another key
to paste it back. Saving ^U is more useful than ^W and starting a new
undo point when you do ^U is probably a reasonable workaround.

If you are interested to take a look anyway, the plugin is available at
http://www.vim.org/script.php?script_id=150, but a newer version can be
downloaded at: http://haridara.googlepages.com/undoins.vim

-- 
Hari

>
> I'm still not 100% sure why I got this craziness:
>
> >> inoremap <c-u> <c-o><nop><c-u>
> >>
> >> This gives me a crazy
> >>
> >> "E486: Pattern not found: insert"
> >>
> >> which, I haven't searched for the word "insert" so this one makes
> >> me scratch my head.  Bug perhaps?  Vim-internals showing through?
>
> to try and reproduce something similar, I did
>
> vim -u NONE
> :set nocp
> :inoremap <c-u> <c-o><Nop><c-u>
>
> inserted some text and hit control+U.  This time I got "E35: No
> previous regular expression".
>
> I suspect that the "<Nop>" isn't getting interpreted as the "do
> nothing" operator as described at
>
>       :help <nop>
>
> but rather is being interpreted as "less-than, en, oh, pee,
> greater-than" and the "en" portion of it is trying to look for
> the last regexp.  I'm not sure how it thought I looked for
> "insert" previously, as I don't consciously remember searching
> for such text this morning.  The docs on <nop> don't seem to
> detail that the only permissible context is a stand-alone <rhs>
> of a mapping.
>
> Ah well.  At least I have the CTRL-G_u functionality to solve the
> problem.  Thanks again,
>
> -tim
>
>
>
>
>


 
____________________________________________________________________________________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.
http://farechase.yahoo.com/promo-generic-14795097

Reply via email to