The VI Editor is the standard editor for Linux systems. And not inferior to any of the other latest editors. But how much is it going to be used? Here's a brief introduction to the VI Editor and some commands. Let's get you on the Linux system.
Basically, vi can be divided into three states, namely command mode, insert mode, and bottom line mode.
1) command-line mode commands to control the movement of the screen cursor, the deletion of characters, words or lines, moving and copying a section and entering insert mode, or to last line mode. 2) Insert mode is only available for text input, and press "esc" to return to command line mode. 3) bottom row mode (last lines) Save or exit VI, or you can set the editing environment, such as searching for strings, listing line numbers ... such as In general, however, we simplify the VI into two modes when we use it, that is, the bottom row mode (last line mode) is also counted as the command-line pattern.
Tools/Materials
Method/Step
-
-
Enter what you want to enter. If you want to exit text-editing mode. And save the text you just edited. First click on "ESC" on the keyboard and enter ": wq!" This saves the text. Then the VI Editor is released. If you do not want to save, click "ESC" on the keyboard and enter ": q!". If you are not sure if you are successful. You can view it through the cat filename command.
The cursor moves in addition to the upper and lower keys on the keyboard. It can also be in lowercase mode, press "H,j,k,l" on the keyboard,
"Ctrl+b": the screen moves backward one page
"ctrl+f": Screen moves forward one page
"Ctrl+u": Screen moves backward half page
"Ctrl+d": Screen moves forward half a page
Enter any integer and enter "Shift+g" to the beginning of this page.
Press the uppercase "G" on the keyboard to move to the end of the article.
Press the "$" symbol to move the cursor to the end of the line
"^" Moves the cursor to the wardrobe
"W": Moves the cursor to the next line header
"B": Contrary to "w". Move to the previous line of the outfit
"E": Moves the cursor to the end of the next line.
If you want the text to display line numbers. In command-line mode, enter the ": Set nu" command at the end of the text. It's okay.
-
copy "yw": Copies the character at the end of the cursor to the buffer. "yy": Copy cursor line to buffer. "#yy": for example, "6yy" represents a copy of 6 lines of text from the line where the cursor is located. "p": Paste the characters in the buffer to the cursor location. Note: All copy commands related to "Y" must be mated with "P" to complete the copy and paste function.
Find
Use "/" plus the content you want to find. For example, "/hello" or "? Hello" is also possible.
- 7
Replace "r": Replaces the character at which the cursor is located. , click on "R" and type. "r": Replaces the character where the cursor is located until the "esc" key is pressed.
- 8
Redo Last Action "u": If you mistakenly execute a command, you can press "u" immediately to go back to the previous action. Multiple restores can be performed by multiple "U". This is equivalent to the "CTRL +z" operation.
Introduction to the use of VI editors in Linux systems