VIEditoris the standard for all UNIX and Linux systemsEditorThat it's powerful not inferior to any of the latest textEditor, here is simply a brief introduction to its usage and a small number of instructions. Because of any version of UNIX and Linux systems,VIThe editor is exactly the same, so you can make any other introductoryVIPlace to learn more about it. VI is also the most basic text editor in Linux, after learning it, you will be in the world of Linux unimpeded.
1, VI of the basic concept
Basically, vi can be divided into three states, namely command mode, insert mode (and bottom line mode), and the function of each mode is as follows:
1) command-line mode
Controls 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
Only in the Insert mode, you can do text input, press "esc" to return to the command line mode.
3) Bottom Line mode
Save or Exit VI, or you can set the editing environment, such as looking for a string, 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.
2, VI of the basic operation
A) Enter VI
After the system prompt symbol to enter VI and file name, go to the VI Full screen editing screen:
$ VI myfile
However, it is important to note that after you enter VI, you are in command mode and you want to switch to insert mode to enter text. First Use VI people will want to use the next key to move the cursor, the result of the computer has been a beep, the gas to death, so enter the VI, do not move, switch to "insert mode" and then!
b) switch to insert mode to edit the file
Press the letter "i" under Command mode to enter "Insert Mode", and you can start typing the text again at this point.
c) Toggle of Insert
You are currently in "Insert Mode", you can only enter text, if you find the wrong word! To move back with the cursor key, delete the word, then click the "esc" key to go to "command mode" and then delete the text.
d) Exit VI and save the file
Under Command mode, click the ":" colon key to enter "last line mode", for example:
: w filename (enter "w filename" to save the article with the filename you specified)
: Wq (input "wq", save and Exit VI)
: q! (Enter q!, do not save the mandatory exit VI)
3. Command mode function key
1). Insert mode
Press "i" switch into insert mode "insert mode", press "I" into the insertion mode is the beginning of the cursor from the current position to enter the file;
After pressing "a" into insert mode, the text is entered from the next position at the current cursor position;
When you press "o" to enter insert mode, you insert a new line and enter text from the beginning of the beginning.
2). Switch from insert mode to command line mode
Press the "esc" key.
3). Move the cursor
VI can be directly on the keyboard with the cursor to move up and down, but the normal VI is the lowercase English letter "h", "j", "k", "l", respectively, control the cursor left, bottom, upper, and right one grid.
Press "ctrl"+"b": The screen moves one page to the back.
Press "ctrl"+"f": The screen moves one page to the front.
Press "ctrl"+"u": The screen moves the half page toward the back.
Press "ctrl"+"d": The screen moves the half page toward the front.
"0" by number: Moves to the beginning of the article.
Press "g": Move to the end of the article.
Press "$": Moves to the end of the line where the cursor is located.
Press "^": Moves to the beginning of the line where the cursor is located
Press "w": Cursor jumps to the beginning of the next word
Press "e": Cursor jumps to the end of the next word
Press "b": Cursor back to the beginning of the last word
Press #l: The cursor moves to the first # position of the line, such as: 5l,56l.
4). Delete text
"x": Each time you press the cursor, delete the "after" character at the position where the pointer is located.
#x: For example, "6x" represents the "after" 6 characters of the location where the cursor was deleted.
"x": Uppercase X, each time it is pressed, deletes the "front" character at the location of the cursor.
"#X": for example, "20x" represents the "front" 20 characters of the location where the cursor was deleted.
"dd": Delete the line where the cursor is located.
"#dd": Deletes the # line starting at the line where the cursor is located
5). Copy
"yw": Copies the characters from the cursor to the end of the word into the buffer.
"#yw": Copy # words to 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.
6). Replace
"r": Replaces the character at which the cursor is located.
"r": Replaces the character where the cursor is located until the "esc" key is pressed.
7). Reply to Last action
"u": If you mistakenly execute a command, you can press "u" immediately to go back to the previous action. Multiple replies can be performed by pressing "U" multiple times.
8). Change
"cw": Change the word-to-tail at the cursor location
"c#w": For example, "c3w" represents a change of 3 words
9). Jump to the specified line
"ctrl"+"g" lists the line number of the line where the cursor is located.
"#G": for example, "15g", which means moving the cursor to the beginning of the 15th line of the article.
Grep-r "Murano".
Find/-name "*murano*"
To view port usage, use the netstat command.
View the connected service ports (established
Netstat-a
View all service ports (listen,established)
Netstat-ap
To view port 8080, you can combine the grep command:
Netstat-ap | grep 8080
If you look at Port 8888, enter it in the terminal:
lsof-i:8888
To stop a program that uses this port, use the Kill + corresponding PID to
chmod u=rwxr,g=xr,o=x manage.py
Linux Shell Command-----VI