Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the vi command of linux

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use linux's vi command, which is very detailed and has a certain reference value. Friends who are interested must finish reading it!

Command to enter vi

Vi filename: open or create a new document and place the cursor at the beginning of the * line

Vi + n filename: open the document and place the cursor at the beginning of line n

Vi + filename: open the document and place the cursor at the beginning of the * line

Vi + / pattern filename: open the document and place the cursor at * strings that match pattern

Vi-r filename: system crash occurred the last time you were editing with vi, restore filename

Vi filename....filename: open multiple documents and edit them in turn

Move cursor class command

H: move the cursor one character to the left

L: move the cursor one character to the right

Space: move the cursor one character to the right

Backspace: move the cursor one character to the left

K or Ctrl+p: move the cursor up one line

J or Ctrl+n: move the cursor down one line

Enter: move the cursor down one line

W or W: move the cursor right one word to the prefix

B or B: move the cursor left one word to the prefix

E or E: move the cursor right one word j to the suffix

): move the cursor to the end of the sentence

(: move the cursor to the beginning of the sentence

}: move the cursor to the beginning of the paragraph

{: move the cursor to the end of the paragraph

NG: move the cursor to the beginning of line n

Nmarker: move the cursor down n lines

Nmury: move the cursor up n lines

Cursor: move the cursor to the end of the nth line

H: move the cursor to the top line of the screen

M: move the cursor to the middle line of the screen

L: move the cursor to the screen * line

0: (note the number zero) move the cursor to the beginning of the current line

$: move the cursor to the end of the current line

Screen tumble command

Ctrl+u: turn half the screen to the first part of the document

Ctrl+d: flip half the screen to the end of the document

Ctrl+f: flip a screen to the end of the document

Ctrl+b; flipped the first screen of the document.

Nz: scroll the nth line to the top of the screen, or the current line to the top of the screen if n is not specified.

Insert text class command

I: in front of the cursor

I: at the beginning of the current line

A: after the cursor

A: at the end of the current line

O: create a new line under the current line

O: open a new line above the current line

R: replace the current character

R: replace the current character and subsequent characters until you press the ESC key

S: replaces the specified number of characters with the entered text, starting at the current cursor position

S: delete the specified number of lines and replace them with the entered text

Ncw or nCW: modifies a specified number of words

NCC: modifies a specified number of rows

Delete command

Ndw or ndW: delete the word NMY at the beginning and after the cursor

Do: delete to the beginning of the line

Delete: delete to the end of the line

Ndd: delete the current line and the subsequent nmur1 line

X or X: delete a character, x after the cursor, and X before the cursor

Ctrl+u: deletes text entered in input mode

Search and replace commands:

/ pattern: search the end of the document for pattern from the beginning of the cursor

Pattern: search the beginning of the document for pattern from the beginning of the cursor

N: repeat the previous search command in the same direction

N: repeat the last search command in the opposite direction

: s/p1/p2/g: replace any p1 in the current line with p2

: N1 Magazine, n2sqqp, p1ax, p2Unique g: replace any p1 in lines N1 to N2 with p2.

: g/p1/s//p2/g: replace any p1 in the document with p2

Option configuration

All: list any option configuration

Term: configure terminal typ

Ignorance: ignore case in search

List: displays the tab stop (Ctrl+I) and the end of line flag ($)

Number: display line number

Report: displays the number of modifications made by line-oriented commands

Terse: displays a short warning message

Warn: displays NO write information if the current document is not saved when you go to another document

Nomagic: allows special characters that are not preceded by "\" in search mode

Nowrapscan: forbids vi to start at the other end of the document when the search reaches the other end

Mesg: allows vi to display information written to their terminals by other users using write

* Line command

: N1 co N2 n3: copy the content between lines N1 and N2 under line n3

: N1 meme N2 m n3: move the content between lines N1 and N2 to the next line n3

: N1 and N2 d: delete the content between N1 lines and N2 lines

W: save the current document

: e filename: open the document filename for editing

X: save the current document and exit

: Q: exit vi

: Qresume: do not save the document and exit vi

:! command: execute the shell command command

: N1 command N2 wicked command: take the contents of lines N1 to N2 in the document as input to the document and execute it, if not specified

If N1 is defined as N2, then the entire document content is used as the input of command.

: ringing command: puts the output of the command command to the current line.

The above is all the contents of the article "how to use the vi Command of linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report