Common vim commands, vim
Vimm (vimsual) is a full-screen editor used in Linux/unix OS.
Vimm is divided into two states: command status and edit status. In command status, the entered character system performs command processing. For example, q indicates that the system exits, the editing status is used to edit text materials. When you enter vim, it first enters the command status. In the command status, press "I" (insert) or "a" (ADD) to enter the editing status. In the editing status, Press ESC to enter the command status.
In the command status, there are some common commands:
New:
A. Add text after the cursor
A. Add text from the end of the row where the cursor is located
Insert:
I insert text from front of the cursor
I insert text from the beginning of the row where the cursor is located
Delete and modify:
X Delete characters at the cursor
Dd deletes the entire row where the cursor is located.
3dd Delete the row where the cursor is located and the following two rows
D. Delete the text from the cursor to the end of the line. It is commonly used to delete the comment Statement (d $)
Move the cursor:
In remote logon mode, vim does not support function keys such as PageUp, PageDown, Home, and End! (Depressing)
^ Move the cursor to the beginning of the line
$ Move the cursor to the end of the row
Ctrl + d flip down half page
Ctrl + f flip down one page
Ctrl + u flip up half page
Ctrl + B turn up one page
Gg move cursor to Document Header
G cursor to end of document
H. move the cursor to the current header.
L move the cursor to the beginning of the last row on the current page
W move one word behind the cursor
B. move the cursor one word forward.
[N] + the cursor moves n rows backward, and [n] indicates an integer.
[N]-move the cursor n rows forward, and [n] indicates an integer
[N] G cursor locates at the beginning of line n, [n] indicates an integer
Search and replace:
/[Str] search string str, [str] indicates the string to be searched
Press enter to highlight all the strings found.
Command n moves to the next string, and command N moves
The previous found string eg/hello
Partially replace (only the row where the cursor is located can be replaced)
:S/[src]/[dst]/I ignore case sensitivity/g all match eg: s/hello/world/ig replace one line
:3, 6 s/[src]/[dst]/ig (found in 3-6 rows) eg: 3, 6 s/hello/world
Replace all
:% S/[src]/[dst]/g replace all src strings in the document with dst strings
:% S/^ // g remove the spaces at the beginning of each line of the document
Block operation:
V visual block selection status. After selecting a block, you can delete the block (d), copy (y), and cut (x)
Yy copy the entire line of the cursor
[N] yy copies n rows starting from the cursor. [n] indicates an integer.
P paste the copied text to the cursor
U undo the last operation
End Editing:
: Q: exit without modifying the document
: Q! Discard Document Modification and force exit
: W document storage
: Wq document disk exited
Others:
: Help command to view the help prompt of this command
: %! Xxd hexadecimal Mode
: %! Xxd-r return text mode
If you accidentally press Ctrl + s during the editing process, vim will be frozen and can be restored by pressing Ctrl + q.
Run vim + 3 main. c // to locate the 3rd line of main. c.
Run vim +/printf main. c // to locate the first printf.
In command mode, enter new2.c // to open a vim file, and use vnew2.c to represent vertical lines.
You can also switch between two windows by using: Ctrl + w, w
Enter gg = G in command mode to automatically align
Sed: Pipeline find replacement program
Cata.txt | sed's/aa/bb/'> B .txt // replace AAAS in a.txt with bbts and output them to B .txt.
: R my_open.c
Read my_open.c to the current directory.
Common commands of the vim Editor, all?
This is a vim tutorial. You can modify it directly. Due to word limit, send it to an email address.
Vim is a powerful editor with many commands. Limited space, in this tutorial
I will not go into details. The purpose of this tutorial is to describe some necessary basic commands.
Some commands, you can easily use vim as a universal editor.
It takes about 25-30 minutes to complete this tutorial, depending on your training time.
The command operations in each section will change this article. We recommend that you copy a copy of this article and
Training (if you start the tutorial through vimtutor, this article is already a copy ).
Remember: the design concept of this tutorial is learned during use. In other words, you need
Execute commands to learn their correct usage. If you only read and do not operate, you may
These commands will soon be forgotten!
Now, please make sure that your Shift-Lock (case-insensitive key) has not been pressed, and then press the key on the disk
The cursor key j is enough times to move the cursor until the content in section 1 is fully filled with the screen.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lecture 1 Section 1: move the cursor
※To move the cursor, press the h, j, k, and l keys respectively. ※※
^
K indicates that the key of h is on the left, and is moved to the left every time you press it.
H l's key is on the right, and will move to the right each time you press it.
The j key looks like a downward arrow at the tip.
V
1. move the cursor freely on the screen until you feel comfortable.
2. Press the downstream key (j) until the cursor repeats.
--- Now you should have learned how to move to the next lecture.
3. now use the downstream key to move the cursor to lecture 2.
Tip: If you are not sure about the letter you press, Press ESC to return to Normal mode.
Enter the command you want on the keyboard again.
Tip: The cursor key should work properly. However, with the hjkl key, you can quickly
Move the cursor around the screen.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lecture 1 Section 2: VIM entry and exit
!! Note: Please read the entire section before you can execute the commands described below.
1. Press ESC (this is to ensure that you are in normal mode ).
2. Enter q! Enter
--- Exiting the editor in this way will never save the changes you have made since entering the editor.
If you want to save the changes and exit, enter:
Wq press ENTER
3. If you see a command line prompt, enter the command that can bring you back to this tutorial, that is:
Vimtutor press ENTER
In general, you can also use this method:
Vim tutor press ENTER
--- 'Vim 'indicates entering the vim Editor, while 'tutor' indicates the file you want to edit.
4. If you are confident that you have kept these steps in mind, please exit from step 1 to step 3.
Then enter the editor again. Next, move the cursor to section 3 of the first lecture to continue our tutorial.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lecture 1 ...... remaining full text>
Common commands of the vim Editor, all?
This is a vim tutorial. You can modify it directly. Due to word limit, send it to an email address.
Vim is a powerful editor with many commands. Limited space, in this tutorial
I will not go into details. The purpose of this tutorial is to describe some necessary basic commands.
Some commands, you can easily use vim as a universal editor.
It takes about 25-30 minutes to complete this tutorial, depending on your training time.
The command operations in each section will change this article. We recommend that you copy a copy of this article and
Training (if you start the tutorial through vimtutor, this article is already a copy ).
Remember: the design concept of this tutorial is learned during use. In other words, you need
Execute commands to learn their correct usage. If you only read and do not operate, you may
These commands will soon be forgotten!
Now, please make sure that your Shift-Lock (case-insensitive key) has not been pressed, and then press the key on the disk
The cursor key j is enough times to move the cursor until the content in section 1 is fully filled with the screen.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lecture 1 Section 1: move the cursor
※To move the cursor, press the h, j, k, and l keys respectively. ※※
^
K indicates that the key of h is on the left, and is moved to the left every time you press it.
H l's key is on the right, and will move to the right each time you press it.
The j key looks like a downward arrow at the tip.
V
1. move the cursor freely on the screen until you feel comfortable.
2. Press the downstream key (j) until the cursor repeats.
--- Now you should have learned how to move to the next lecture.
3. now use the downstream key to move the cursor to lecture 2.
Tip: If you are not sure about the letter you press, Press ESC to return to Normal mode.
Enter the command you want on the keyboard again.
Tip: The cursor key should work properly. However, with the hjkl key, you can quickly
Move the cursor around the screen.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lecture 1 Section 2: VIM entry and exit
!! Note: Please read the entire section before you can execute the commands described below.
1. Press ESC (this is to ensure that you are in normal mode ).
2. Enter q! Enter
--- Exiting the editor in this way will never save the changes you have made since entering the editor.
If you want to save the changes and exit, enter:
Wq press ENTER
3. If you see a command line prompt, enter the command that can bring you back to this tutorial, that is:
Vimtutor press ENTER
In general, you can also use this method:
Vim tutor press ENTER
--- 'Vim 'indicates entering the vim Editor, while 'tutor' indicates the file you want to edit.
4. If you are confident that you have kept these steps in mind, please exit from step 1 to step 3.
Then enter the editor again. Next, move the cursor to section 3 of the first lecture to continue our tutorial.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lecture 1 ...... remaining full text>