Vi editor introduction, vi editor Introduction

Source: Internet
Author: User

Vi editor introduction, vi editor Introduction
Part 1: Mode

Three modes: Command mode (default mode), edit mode, and baseline command mode

Command mode --> edit mode (I/o/a/r)

Edit mode --> command mode (esc)

Command mode --> baseline command (:)

Baseline command --> command mode (esc)

I, lowercase, insert at current position

I, uppercase, insert at the beginning of the line

A, lower case, insert after current position

A, in upper case, insert at the end of the row

O, lower case, new row

O, in upper case, the previous line

S, in lower case. Delete the character of the cursor and insert it at the current position.

S. in upper case, delete the row where the cursor is located and insert the current row.

Part 2: Mouse

2.1 move the mouse

2.2 hjkl (bottom left)

First row of 2.3, end of row ^ $

2.4 first line of the file, end line gg, G

2.5 integer + G

2.6 A word w and B can be used with N in the next word.

Part 3: copy and paste commands

3.1 yy: copy a row

3.2 10yy, copy 10 rows

3.3 yw, copy a word

3.4 million, copy 10 words

3.5 p pre-paste P post-paste

3.6 dd delete a row 10dd Delete 10 rows

3.7 dw Delete word 10dw Delete ten words

3.8 x Delete the current character

The deletion of 3.9 vi is equivalent to cutting. You can paste it after executing the p command.

Part 4: undo

4.1 u for revocation

4.2 ctrl + r redo

4.3. Repeat the last command

4.4 J Merge multiple rows

Part 5: bottom-line command mode

5.1: w, saved directly

5.2: w file, save as new file

5.3: wq !, Force save and exit

5.4: q !, Force exit

Part 6: search and replace

6.1/down search

6.2 search up

6.3: s/search/replace

6.4: s/search/replace/g full-text replace

6.5: % s/search/replace in-row replacement

6.6: setnu display row number

Part 7: Configuration

7.1 global configuration vi/etc/virc

7.2 user configuration vi ~ /. Vimrc

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.