Home Explore Blog CI



neovim

3rd chunk of `runtime/doc/usr_02.txt`
152e6640e344c4f3552dc5d52b057689f6817ff0141eeda70000000100000fa1
 nice way to learn by doing.

For Japanese users, Hiroshi Iwatani suggested using this:

			Komsomolsk
			    ^
			    |
	   Huan Ho	<--- --->  Los Angeles
	(Yellow river)	    |
			    v
			  Java (the island, not the programming language)

==============================================================================
*02.4*	Deleting characters

To delete a character, move the cursor over it and type "x".  (This is a
throwback to the old days of the typewriter, when you deleted things by typing
xxxx over them.)  Move the cursor to the beginning of the first line, for
example, and type xxxxxxx (seven x's) to delete "A very ".  The result should
look like this:
>
	+---------------------------------------+
	|intelligent turtle			|
	|Found programming Unix a hurdle	|
	|~					|
	|~					|
	|					|
	+---------------------------------------+
<
Now you can insert new text, for example by typing: >

	iA young <Esc>

This begins an insert (the i), inserts the words "A young", and then exits
insert mode (the final <Esc>).	The result:
>
	+---------------------------------------+
	|A young intelligent turtle		|
	|Found programming Unix a hurdle	|
	|~					|
	|~					|
	|					|
	+---------------------------------------+
<

DELETING A LINE

To delete a whole line use the "dd" command.  The following line will
then move up to fill the gap:
>
	+---------------------------------------+
	|Found programming Unix a hurdle	|
	|~					|
	|~					|
	|~					|
	|					|
	+---------------------------------------+
<

DELETING A LINE BREAK

In Vim you can join two lines together, which means that the line break
between them is deleted.  The "J" command does this.
   Take these two lines:

	A young intelligent ~
	turtle ~

Move the cursor to the first line and press "J":

	A young intelligent turtle ~

==============================================================================
*02.5*	Undo and Redo

Suppose you delete too much.  Well, you can type it in again, but an easier
way exists.  The "u" command undoes the last edit.  Take a look at this in
action: After using "dd" to delete the first line, "u" brings it back.
   Another one: Move the cursor to the A in the first line:

	A young intelligent turtle ~

Now type xxxxxxx to delete "A young".  The result is as follows:

	 intelligent turtle ~

Type "u" to undo the last delete.  That delete removed the g, so the undo
restores the character.

	g intelligent turtle ~

The next "u" command restores the next-to-last character deleted:

	ng intelligent turtle ~

The next "u" command gives you the u, and so on:

	ung intelligent turtle ~
	oung intelligent turtle ~
	young intelligent turtle ~
	 young intelligent turtle ~
	A young intelligent turtle ~

REDO

If you undo too many times, you can press CTRL-R (redo) to reverse the
preceding command.  In other words, it undoes the undo.  To see this in
action, press CTRL-R twice.  The character A and the space after it disappear:

	young intelligent turtle ~

There's a special version of the undo command, the "U" (undo line) command.
The undo line command undoes all the changes made on the last line that was
edited.  Typing this command twice cancels the preceding "U".

	A very intelligent turtle ~
	  xxxx				Delete very

	A intelligent turtle ~
		      xxxxxx		Delete turtle

	A intelligent ~
					Restore line with "U"
	A very intelligent turtle ~
					Undo "U" with "u"
	A intelligent ~

The "U" command is a change by itself, which the "u" command undoes and CTRL-R
redoes.  This might be a bit confusing.  Don't worry, with "u" and CTRL-R you
can go to any of the situations you had.  More about that in section |32.2|.

==============================================================================
*02.6*	Other editing commands

Vim has a large number of commands to change the text.  See |Q_in| and below.
Here are a few often used ones.


APPENDING

The "i" command inserts a character before the character under the cursor.
That works fine; but what happens if you want to add

Title: Deleting Lines, Undoing, and Other Editing Commands in Vim
Summary
This section explains how to delete an entire line using 'dd' and join two lines with 'J'. It also covers undoing changes with 'u' and redoing them with Ctrl-R. There's also a special version of the undo command, the 'U' (undo line) command which undoes all changes made on the last line. Finally, it introduces the 'i' command, which inserts a character before the character under the cursor.