Vim simple text editing commands

Source: Internet
Author: User

<blockquote>:e! Enter</blockquote>
Eliminate all of this editing, back to the original file look. However, this file is still open.
<blockquote>:q! Enter</blockquote>
Eliminate all edits, return to the original file, and leave Vim.
<blockquote>:w! FileName

: w! Newfilename</blockquote>
If the file exists, overwrites the existing file, creates a new file if the file does not exist, and writes the content to the new file.
<blockquote>hjkl</blockquote>
Move up or down.

&nbsp;

Move in one line:
<blockquote>0 move to the beginning of a line

$ move to the end of a line

W e B-word movement </blockquote>
To change the text:
<BLOCKQUOTE>CW changes from the cursor to the end of the word

C2B 2 Words forward from the cursor

C $ from cursor to end of bank

C0 from the cursor to the beginning of the bank

c^ from the cursor to the beginning of the bank is not a space

CC entire line of content changes, the original cursor position is not important, it will directly replace the entire row of text </blockquote>
General form of the VI command:
<blockquote> (command) (text object)

(command) (number) (Text object)

(number) (command) (Text object)

Command section is the change commands c,d,y etc.

The text object is the cursor Movement command w,b,0,$, etc.

Number is the digital </blockquote>
Changes to Characters:
<blockquote>r replace one character with another, and the end does not need to press ESC.

X Remove a character

5x Delete 5 characters

XP Exchange two characters

~ Change Case </blockquote>
Delete command:
<BLOCKQUOTE>DW Delete the word at the cursor position, and the whitespace after the word is deleted

DB to delete a word forward

d$ D0

DD Delete entire row

2DD Delete 2 rows

d=d$ Delete cursor to entire line end </blockquote>
Moving text, using the "delete and Post text" method in VI, moves the text as if it were cut and paste.
<blockquote>p put puts the text of the buffer behind the cursor, and the uppercase P command places the text before the cursor. If you move more than one line of text, the p command places the moved text on a new line after the cursor, and if you move the text less than one line, the P command places the moved text on the same line after the cursor.

Y Yank copy a piece of text and use it elsewhere, YP can be used with any move command, such as Yw,y$,4yy</blockquote>
Repeat a command:
<blockquote>. Period to repeat the previous edit command </blockquote>
To undo a command:
<blockquote>u Undo Previous Command </blockquote>
&nbsp;

More ways to insert text:
<blockquote>a append text at the end of a line

I insert text at the beginning of a line

o Open a new line at the next line where the cursor is located

O open a new line on the previous line at the cursor position

s delete the character at the cursor position before replacing the text

S deletes a whole line before replacing the text

R overwrites existing characters with new characters </blockquote>
Numeric parameters for the Insert command:
<blockquote>50i*esc insertion of 50 asterisks

25a*. ESC Insert 25 Pair *.</blockquote>
&nbsp;
<blockquote>j Merge two lines </blockquote>

Vim simple text editing commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.