linux vi command

silencement
Release: 2019-06-05 10:15:22
Original
2679 people have browsed it

linux vi command

Commonly used vi commands under Linux are:

Commands to enter vi

vi filename: open or create a 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 the nth line

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: The system crashed when editing with vi last time , restore filename

vi filename....filename: Open multiple files and edit them in sequence

Move cursor command
h: Move the cursor one to the left Character
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 one word to the right to the beginning
b or B : Move the cursor one word to the left to the beginning
e or E : Move the cursor one word to the right to the end
) : 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: The cursor moves to the beginning of the nth line
n: The cursor moves down n lines
n-: The cursor moves up n lines
n$: The cursor moves to the end of the nth line
H: The cursor moves to the top line of the screen
M: The cursor moves to the middle line of the screen
L: The cursor moves to the last line of the screen
0: (note the number zero) The cursor moves to the beginning of the current line
$: Move the cursor to the end of the current line

Screen scrolling commands
Ctrl u: Scroll half-screen to the beginning of the file
Ctrl d: Scroll half-screen to the end of the file
Ctrl f: Scroll one screen to the end of the file
Ctrl+b; Scroll one screen to the beginning of the file
nz: Scroll the nth line to the top of the screen. If n is not specified, the current line will be scrolled to the top of the screen.

Delete command
ndw or ndW: delete the n-1 characters starting at the cursor and following it
do: delete to the beginning of the line
d$: delete to the end of the line
ndd: Delete the current line and n-1 lines after it
x or X: Delete a character, x deletes the one after the cursor, and

Search and replace commands
/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 last search command in the same direction
N: Repeat the last search command in the opposite direction
: s/p1/p2/g: Replace all p1 in the current line with p2
: n1, n2s/p1/p2/g: Replace all p1 in the n1 to n2 lines with p2
: g/p1/s//p2/g: Replace all p1 in the file with p2

Option settings
all: List all option settings
term: Set the terminal type
ignorance: Ignore case in search
list: Display tab stops (Ctrl I) and the end-of-line flag ($)
number: Displays the line number
report: Displays the number modified by the line-oriented command
terse: Displays a brief warning message
warn: Go to If the current file is not saved in other files, the NO write message will be displayed
nomagic: Allow the use of special characters without "\" in front of the search mode
nowrapscan: Prohibit vi from searching at both ends of the file. Start from the other end again
mesg: Allow vi to display information written by other users to their own terminals using write

The above is the detailed content of linux vi command. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template