"Linux" VI command

Source: Internet
Author: User

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

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.