Vim Tips Wiki
No edit summary
 
(Uploaded by JohnBot from a locally edited file)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=86
 
|id=86
  +
|previous=85
|title=Helps undo 1 line when entered many
 
  +
|next=87
|created=July 9, 2001 9:38
+
|created=July 9, 2001
 
|complexity=basic
 
|complexity=basic
|author=Stepan Koltsov <yozh--AT--mx1.ru>
+
|author=Stepan Koltsov
 
|version=5.7
 
|version=5.7
 
|rating=3/6
 
|rating=3/6
 
}}
|text=
 
When U entered text, U cannot undo only 1 line, for example, when U press "u", all entered in last "insert" text removed.
+
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 &lt;Return&gt; &lt;Return&gt;^O^[
   
 
where "^O" or "^[" is 1 char
If U add this line to .vimrc:
 
   
 
"u" will undo (remove) only 1 line.
inoremap &lt;Return&gt; &lt;Return&gt;^O^[
 
   
 
==Comments==
where "^O" or "^[" is 1 char
 
 
"u" will undo (remove) only 1 line.
 
 
 
}}
 
 
== Comments ==
 
nice tip. but U definitely should improve your English :)
 
 
rnd--AT--softhome.net
 
, July 9, 2001 14:26
 
 
----
 
----
 
First idea -- write:
Thanks for advice (about English :) Anywhen I'll learn it :)
 
 
:inoremap &lt;return&gt; &lt;return&gt;a^Ox
   
 
it works, but it looks not nice.
I saw 1 bug of this tip: autoindent don't work. How to correct this?
 
   
Yozh.
 
 
yozh--AT--mx1.ru
 
, July 13, 2001 11:17
 
 
----
 
----
 
That mapping causes a problem if you break an existing line up, for e.g. if have the following line.
Sorry my English again :)
 
 
TextOnALine
   
 
pressing return in between 'Text' And 'OnALine' will give you..
First idea -- write:
 
 
Text
:inoremap &lt;return&gt; &lt;return&gt;a^Ox
 
 
ananALine
it works, but it looks not nice :(
 
I know vim too bad...
 
   
 
The 'O' gets replaces with the 'a'.
Yozh.
 
 
yozh--AT--mx1.ru
 
, July 13, 2001 11:22
 
----
 
And Yozh solution is not causes a beep
 
 
kgergely--AT--mcl.hu
 
, January 9, 2002 6:36
 
----
 
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 &lt;Left&gt; seems to work ok for me
+
Adding a &lt;Left&gt; seems to work ok for me
inoremap &lt;return&gt; &lt;return&gt;a&lt;Left&gt;^Ox
+
inoremap &lt;return&gt; &lt;return&gt;a&lt;Left&gt;^Ox
   
drennalls--AT--gmail.com
 
, November 18, 2004 10:36
 
 
----
 
----
<!-- parsed by vimtips.py in 0.697162 seconds-->
 

Revision as of 10:36, 30 October 2007

Tip 86 Printable Monobook Previous Next

created July 9, 2001 · complexity basic · author Stepan Koltsov · version 5.7


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 <Return> <Return>^O^[

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

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

Comments


First idea -- write:

:inoremap <return> <return>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 <return> <return>a<Left>^Ox