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

What are the common commands of vi under linux

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Editor to share with you what vi commands are commonly used under linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The common commands for vi under linux are:

Command to enter vi

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

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

Vi + filename: open the file and place the cursor at the beginning of the last line

Vi + / pattern filename: open the file and place the cursor at the first string that matches pattern

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

Vi filename....filename: open multiple files 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 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 last line of the screen

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 file

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

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

Ctrl+b; flipped through the first screen of the file.

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.

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 command

/ pattern: search for pattern from the beginning of the cursor to the end of the file

Pattern: search for pattern from the beginning of the cursor to the beginning of the file

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 all p1 with p2 in the current line

: N1 Magazine, n2sqqp1, p2Unix, g: replace all p1 with p2 in lines N1 to N2.

: g/p1/s//p2/g: replace all p1 in the file with p2

Option settin

All: lists all option settings

Term: setting terminal type

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 file is not saved when transferring to another file

Nomagic: allows special characters not preceded by "\" to be used in search mode

Nowrapscan: forbids vi to start from the other end when the search reaches both ends of the file

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

The above are all the contents of the common vi commands under linux. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more 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: 263

*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