Introduction to common Linux Vi/Vim operation commands and linuxvivim commands

Source: Internet
Author: User

Introduction to common Linux Vi/Vim operation commands and linuxvivim commands
1. Enter the vi/vim text editor command

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 line n
Vi + filename: open the file and place the cursor in the last row
Vi +/pattern filename: open the file and place the cursor at the beginning of the first line matching pattern
Vi-r filename: restores the filename file after the system crashes during the last time the vim text editor was requisitioned.
Vi filename1... Filenamen: the linux vi/vim text editor can open multiple files and edit them in sequence.
2 linux vi/vim command for moving the cursor in the text editor
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: move the cursor to the beginning of the current row
$: Move the cursor to the end of the current row
3 linux vi/vim text editor screen tumble command
Ctrl + F: Forward the entire page
Ctrl + U: half page forward
Ctrl + B: Flip the whole page backwards
Ctrl + D: half page backward
4 Linux vi/vim text editor insert text commands
I: Before the cursor
I: at the beginning of the current row
A: After the cursor
A: At the end of the current row
O: open a new row under the current row
O: open a new row before the current row.
5 Linux vi/vim text editor DELETE command
Do: Delete to the beginning of a row
D $: Delete to the end of the row
Dd: Delete the row where the cursor is located.
Ndd: delete a forward flight and the next n-1 line
D: Delete the content from the current cursor to the end of the row.
Ctrl + u: delete all text entered in input mode
6 search and replace commands in Linux vi/vim Text Editor
/Pattern: Search for the pattern from the beginning of the cursor to the end of the file
? Pattern: searches for the pattern at the beginning of the cursor.
: S/p1/p2/g: replace all p1 in the current row with p2
: N1, n2s/p1/p2/g: replace all p1 from line n1 to line n2 with p2
: G/p1/s // p2/g: replace all p1 in the file with p2
7 Linux vi/vim text editor copy and paste commands

In the vi/vim text editor, "y" indicates copying, "d" indicates deleting, and "p" indicates pasting. It is usually used in combination with the cursor movement command.

Y $: Indicates copying the content from the current cursor to the end of the row.
D $: deletes the content from the current cursor to the end of the row.
Yy: copy the row where the cursor is located
8. Undo operation commands in Linux vi/vim Text Editor
U: cancel the last operation
U: cancel all operations
9 vi/vim editor command in last line mode
N1, n2 d: Delete content between n1 row and n2 row
: W: Save the current file
: E filename open file filename for editing
: X Save the current file and release it
: Q exit vi/vim Editor
: Q! Do not save and exit vi/vim Editor

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.