Text Editor Vim/VI

Source: Internet
Author: User

I,
Official Website

Www.vim.org

II,
VI Working Mode

Command mode, insert mode, and edit mode.

III,
Go to VI

1.
Use VI to open a file.

2.
Directly go to the specified location.

1)
Vi + 20/etc/passwd

2)
Vi +/root/etc/passwd

IV,
VI Basic Applications

1.
INSERT command: I, A, O.

2.
Cursor movement command

1)
Movement in characters: H, J, K, L

2)
Move in words: W, B, E

3)
Move to the beginning or end of a row: $ (N $), 0

4)
Move to the specified character in a row: F (move the cursor to a specific character in the current row, FA)

5)
Move to matching brackets: %

6)
Move to the specified row: NG

7)
Move to the last line: gg

3.
Use VI for editing

1)
Search for a string: "/string to be searched" (Backward Search), "? The string to be searched (Forward search),/^ root (the row ending with root), And/root $ (the row starting with root)

2)
Replace with VI: ": Replace the start position, replace the end position S/string to be replaced/Replace the string/g" (for example, ": 1, $ S /:/, /g)

3)
Use VI to delete, paste, and copy: X, DD, NDD, P, YY, nyy, J, U, CTRL + R (excessive undo, re-Execute UNDO)

4.
Save the exit command: W, Q ,!, W
Path/new file name, ZZ (in command mode)

V,
VI advanced applications

1.
Show row number: Set Nu, set Nonu

2.
Multi-Window Editing: ": SP another file", CTRL + W + k, CTRL + W + J, ": R
Copied file name"

3.
Copy region: Ctrl + V-> select region-> Y-> move to target location-> P

4.
Interaction with Shell in VI ::!
Command

 

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.