Vim Tips Wiki
Register
(Adding categories)
(Adjust previous/next navigation + minor manual clean)
Line 5: Line 5:
 
|previous=85
 
|previous=85
 
|next=87
 
|next=87
|created=July 9, 2001
+
|created=2001
 
|complexity=basic
 
|complexity=basic
 
|author=Stepan Koltsov
 
|author=Stepan Koltsov
|version=5.7
+
|version=6.0
 
|rating=3/6
 
|rating=3/6
|category1=
+
|category1=Undo
 
|category2=
 
|category2=
 
}}
 
}}
Line 16: Line 16:
   
 
If you add this line to [[vimrc]]
 
If you add this line to [[vimrc]]
  +
<pre>
 
inoremap <CR> <CR>^O^[
+
inoremap <CR> <CR>^O^[
  +
</pre>
   
 
where "^O" or "^[" is 1 char
 
where "^O" or "^[" is 1 char
Line 25: Line 26:
 
==Comments==
 
==Comments==
 
First idea -- write:
 
First idea -- write:
  +
<pre>
:inoremap <CR> <CR>a^Ox
+
:inoremap <CR> <CR>a^Ox
  +
</pre>
   
 
it works, but it looks not nice.
 
it works, but it looks not nice.
Line 40: Line 43:
   
 
Adding a <Left> seems to work ok for me
 
Adding a <Left> seems to work ok for me
  +
<pre>
inoremap <CR> <CR>a<Left>^Ox
+
inoremap <CR> <CR>a<Left>^Ox
  +
</pre>
   
 
----
 
----
[[Category:Undo]]
 

Revision as of 10:51, 23 September 2009

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.

Comments

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