how to undo only the latest inserted character?

1 view
Skip to first unread message

aleCodd

unread,
Sep 8, 2010, 5:23:22 PM9/8/10
to v...@vim.org

the undo seems to change all text inserted since insert-mode was started.

but what if i want to undo only one character, specifically if i mapped let
say like this:
ino a abc
now after i start again the insert mode and type some text and the 'a'
character which is mapped to 'abc', how do i undo only these three ('abc')
characters?

cheers
--
View this message in context: http://vim.1045645.n5.nabble.com/how-to-undo-only-the-latest-inserted-character-tp2818354p2818354.html
Sent from the Vim - General mailing list archive at Nabble.com.

Tim Chase

unread,
Sep 8, 2010, 8:54:00 PM9/8/10
to vim...@googlegroups.com, aleCodd, v...@vim.org
On 09/08/10 16:23, aleCodd wrote:
>
> the undo seems to change all text inserted since insert-mode was started.
>
> but what if i want to undo only one character, specifically if i mapped let
> say like this:
> ino a abc
> now after i start again the insert mode and type some text and the 'a'
> character which is mapped to 'abc', how do i undo only these three ('abc')
> characters?

I don't know of anything natively, but you might be able to use
"control-g u"

:help i_CTRL-G_u

in your mapping and/or abbreviation to set undo points before you
expand your mapping/abbr. Then a regular undo will do what you
want. You might try something like

:ino a <c-g>uabc

or

:iab a ^Guabc

(where the ^G may need to be entered as control+V followed by
control+G)

-tim

Reply all
Reply to author
Forward
0 new messages