Use of the VI command under Linux

Source: Internet
Author: User

1. Read and write status switch

A: Write

ESC: Read

2. Save and exit

Save: W

Exit: Q

Save exit: Wq

Add an exclamation mark to force save or exit: w!, q!

3. Jump to the end of the line

0: Jump to the beginning of the line

shift+$: Jump to end of line

4. Copy, cut/delete rows, paste

Single-line replication: yy

MultiRow copy: Nyy

Single-line cut/delete: DD

Multi-line Cut/delete: NDD

Paste: P

5. Find

/pattern: Find pattern Match string down

? pattern: Find pattern Match string up

N: Continue searching in the same direction

N: Continue searching in the opposite direction

Pattern can contain special characters, including spaces,/, ^, $, *,.

6. Replace

: s/vivian/sky/#替换当前行第一个 Vivian for Sky

: s/vivian/sky/g #替换当前行所有 Vivian for Sky

: N, $s/vivian/sky/#替换第 the first Vivian of each row in line n start to the last row is sky

: N, $s/vivian/sky/g #替换第 n lines start to the last row all Vivian for each row are sky

(n is a number, if N is., representing the beginning of the current line to the last row)

:%s/vivian/sky/# (equivalent to: g/vivian/s//sky/) replaces the first Vivian of each line as Sky

:%s/vivian/sky/g # (equivalent to: g/vivian/s//sky/g) replaces all Vivian in each row as Sky

7, display line number

: Set Nu

8. Comment Lines

Comment Line: #

9. Jump to a line

: LineNum

10, jump to the end of the file

Jump to end of file: Shift+g

Jump to the beginning of the file: GG

Finally attached an old picture, personally feel very useful

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/85/5C/wKioL1ehhDuShYF6AATsZ3_vMHU740.png "title=" vi.png "alt=" Wkiol1ehhdushyf6aatsz3_vmhu740.png "/>

This article is from the "袁喆玺 blog" blog, make sure to keep this source http://yuanzhexi.blog.51cto.com/7786823/1833924

Use of the VI command under Linux

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.