Wikia

Vim Tips Wiki

Watchlist Recent changes

Helps undo 1 line when entered many

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 86 Printable Monobook Previous Next

created 2001 · complexity basic · author Stepan Koltsov · version 6.0


When you entered text, you cannot undo only 1 line, for example, when you press "u", all entered in last "insert" text removed.

If you add this line to vimrc

inoremap <CR> <CR>^O^[

where "^O" or "^[" is 1 char

"u" will undo (remove) only 1 line.

CommentsEdit

First idea -- write:

:inoremap <CR> <CR>a^Ox

it works, but it looks not nice.


That mapping causes a problem if you break an existing line up, for e.g. if have the following line.

TextOnALine

pressing return in between 'Text' And 'OnALine' will give you..

Text
ananALine

The 'O' gets replaces with the 'a'.

Adding a <Left> seems to work ok for me

inoremap <CR> <CR>a<Left>^Ox

You could also map <CR> to start a new undo sequence using <C-G>u

:inoremap <CR> <C-G>u<CR>

Chrisbra 08:51, May 13, 2010 (UTC)

Pages on Vim Tips Wiki

Add a Page
1,586pages on
this wiki
Advertisement | Your ad here

Latest Photos

Add a Photo
71photos on this wiki
See more >

Recent Wiki Activity

See more >

Around Wikia's network

Random Wiki