How to use the Vim editor in Linux

Source: Internet
Author: User

Vim is the most common type of text editing software for Linux systems, and almost any Linux distribution will install this software by default. Although there are many text editing software for Linux Now, there is no substitute for the power of vim.

VIM has three modes: instruction mode, insert mode, and Bottom line command mode. Only in the Insert mode, you can edit, instruction mode and bottom line command mode, you can delete, copy, paste and find a variety of behaviors.

------------------------------------------------the operation of the command mode into insert mode------------------------------

A: Insert the content after the cursor.
A: Inserts the content at the end of the current line.
O: Insert content below the current line
O: Insert content above the current line
I: inserting content at the cursor
I: Insert content at the beginning of the current line

ESC can go back to command mode from insert mode

-----------------------------------------------The jump command in command mode----------------------------------------

GG: Back to the beginning of the first line of the file
10gg: Jumps to the 10th line of the file. 22gg Line 22nd.
G: Jumps to the last line of the file

H: The first line of the current screen
M: middle of current screen
L: The last line of the current screen

W: one word, one word, right jump.
B: One word, one word, left jump.
F: Follow the letter that you want to jump, such as: F B jumps right to the nearest B letter

Home: Jumps to the beginning of the current line
End: Jumps to the end of the current line

--------------------------------------------common operations in text-----------------------------------------------------

YY: Copy when moving forward
10yy: Copy 10 rows down from the current line. 20yy
YW: Copy a word
y$: Copy all the contents of the cursor at the end of the line
y^: Copy all content at the beginning of the cursor

P: Paste at cursor location

DD: Delete When moving forward
DDP: Swapping up and down lines
10DD: Deletes 10 rows from the current line. 20dd
DW: Delete a word
d$: Delete all content at the end of the line at the cursor
d^: Delete all content at the beginning of the cursor
x: Delete a character at the cursor

R B: Replace the character at the cursor with B and then: R N Replace the character at the cursor with n
R: Continuously right from the cursor until you press the ESC key to stop

U: Undo Previous Action
U: Undo all changes to the current row
Ctry+r: Anti-revocation

--------------------Enter in command mode: Enter the last line mode--------------------------------------------------

W: Save
Q: Exit
WQ: After saving, exit is the same as X.
q!: Do not save exit

Set Nu: Display line number
Set Nonu: Line numbers are not displayed

W Aa.log: Save the current file as Aa.log in the current directory
W/tmp/ab.log: Save the current file as Ab.log in the/tmp directory

1090,1096 W 1090.log: Saves 1090 rows to 1096 rows of the current file to 1090.log in the current directory.

1085,1088s/^/#/g: Inserting # 1085 lines to 1088 lines at the beginning #
1085,1088s/^#//g: Remove 1085 lines to 1088 lines at the beginning of the #
%s/^c/c/g: Replace all content with C in the current document with C

R Aa.log reads the Aa.log file from the current directory into the current file until the effect of the file merge

How to use the Vim editor in Linux

Related Article

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.