In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "vi's command summary". In daily operation, I believe many people have doubts about vi's command summary. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope it will help you answer the doubts of "vi's command summary"! Next, please follow the small series to learn together!
**********
**** Command to enter vi ***
**********
vi filename : Open or create a new file with 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 matching pattern
vi -r filename: system crash occurred when last edited with vi, restore filename
vi filename.... filename: Open multiple files and edit them in turn
**********
**** Move Cursor Command [/b]****
**********
h: Move cursor left one character
l: Move the cursor one character to the right
space: Move the cursor one character to the right
Backspace: Move the cursor left one character
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 beginning
b or B: Move the cursor left one word to the beginning
e or E: Move the cursor right one word to the end
Move cursor to end of sentence
Move cursor to the beginning of sentence
}: Move cursor to beginning of paragraph
{: Cursor moved to end of paragraph
nG: Move cursor to the beginning of line n
n+: cursor down n lines
n-: Move cursor up n lines
n$: Move cursor to end of nth row
H: Move cursor to top line of screen
M: Move cursor to middle row of screen
L: Move cursor to the last line of screen
0:(Note the number zero) Cursor moves to the current line
$: cursor moves to end of current line
**********
**** Screen Tumble Command ***
**********
Ctrl+u: Flip half screen to the first part of the file
Ctrl+d: Flip half screen to end of file
Ctrl+f: Flip one screen to the end of the file
Ctrl+b; Flips to the first screen of the document
nz: Scrolls the nth row to the top of the screen, or scrolls the current row to the top of the screen if n is not specified.
Insert Text Class Command
i: Before 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 below the current line
O: Create a new line above the current line
r: Replace the current character
R: Replace the current character and subsequent characters until ESC is pressed
s: Replace 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 n-1 words beginning and following the cursor
Do: delete to the beginning of the line
d$: Delete to end of line
ndd: delete the current row and the next n-1 rows
x or X: deletes a character, x deletes after the cursor, and X deletes before the cursor
Ctrl+u: Delete text entered in Input Mode
**********
**** Search and Replace Life ***
**********
/pattern: Search for pattern from the cursor to the end of the file
? pattern: Search for pattern from the cursor to the beginning of the file
n: Repeat previous search command in same direction
N: Repeat the last search command in the opposite direction
: s/p1/p2/g: Replace all p1s in the current row with p2
: n1,n2s/p1/p2/g: Replace all p1 with p2 in rows n1 to n2
: g/p1/s//p2/g: Replace all p1's with p2's in the file
**********
**** Option Settings ***
**********
all: List all option settings
term: Set terminal type
ignorance: Ignore case in search
list: Display tab stops (Ctrl+I) and end-of-line flags ($)
number: Display line number
report: Displays the number of changes made by line-oriented commands
terse: Display a short warning message
warn: When you go to another file, if the current file is not saved, the NO write message will be displayed
nomagic: Allows special characters not preceded by "\" to be used in search mode
nowrapscan: prohibit vi from searching both ends of a file and starting from the other end
mesg: allows vi to display information written by other users to their own terminal with write
**********
**** Last Line Mode Command *******
**********
: n1,n2 co n3: copy the contents between line n1 and line n2 to line n3
: n1,n2 m n3: Move the content between lines n1 and n2 to line n3
: n1,n2 d: delete the contents between lines n1 and n2
: w: Save the current file
: e filename: open file filename for editing
: x: Save the current file and exit
Q: Exit VI
:q!:Do not save files and exit vi
:! Command: Executing the Shell Command
:n1,n2 w! command: input and execute the contents of line n1 to line n2 in the file as command, if n is not specified
1, n2, then the entire file content is input as command
:r! command: Put the output of command on the current line
**********
**** Register operation ***
**********
"? nyy: Save the contents of the current line and the next n lines into a register? Among them? is a letter and n is a number.
"? nyw: Save the current line and the next n words to a register? Among them? is a letter and n is a number.
"? nyl: Save the current line and the next n characters to a register? Among them? is a letter and n is a number.
"? P: Take out the register? and drop it at the cursor position. Here? It can be a letter or a number.
ndd: delete the text of the current line and its next n lines, and put the deleted contents into the delete register No.1.
At this point, the study of "vi command summary" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.