Basically, Vi/vim is divided into three modes, namely, General mode, edit mode and command-column mode. The three modes of action are:
General mode:
Open a file with VI directly into the general mode (this is the default mode). In this mode, you can use the "up or down" button to move the cursor, you can use "delete character" or "Delete whole line" to process the contents of the file, you can also use "copy, paste" to process your data.edit mode:
In general mode can be deleted, copied, pasted and so on, but can't edit the contents of the file! Wait until you press "I, I, O, O, A, a, R, R," and any one of the letters before entering edit mode. Watch out! Usually in Linux, when you press these keys, the words "INSERT or REPLACE" appear at the bottom left of the screen, so you can edit them. If you want to return to normal mode, you must press the "ESC" button to exit edit mode.Instruction-column command mode:
In the general mode, enter ":/? "Any one of the three buttons, you can move the cursor to the bottom row." In this mode, you can provide "search data" action, and read, save, a large number of substitution characters, leave VI, display line number and so on the action is achieved in this mode! 1. Open Filecommand name: vi or view[[email protected]test]# VI stariboss_build.sh #!/bin/bash#storagepath=$1#deploydirectriespath=$2 ####### for TESTING ######## Storagepath= "/home/redis/test" deploydirectriespath= "/home/redis/test"
: w Save;
: w filename saved as filename;
: wq! Save exit;
: wq! FileName Note: The filename is saved and then exited;
: q! Do not save the exit;
: x Save and exit, function and: wq! same
2. Modify the file Insert: Press I into the edit mode can be added to modify the deletion, OK, press ESC to exit the edit mode, enter the command:: Wq, enter is the save exit.
"Linux" VI command