Linux Utility VI

Source: Internet
Author: User
Tags delete key save file

VI has both input and command modes of operation. Command mode is used to run commands such as arranging files, archiving, and leaving VI. When the VI is executed, first enter the command mode, at which point the number of characters entered is considered a command.

in command mode, the following two keys can be used to enter the text  input mode " a key " : Add text after the current cursor  A for append"i key ": Add text   before the current cursor I for insert in input mode, if the user wants to return to the command mode,  can only use the ESC key in input mode to switch to command mode, then the cursor at the bottom of the screen will wait for the input command 

Create a new document using VI--at the Linux Terminal command main prompt, enter VI. --Press the"a"key, enter the input mode, use the BACKSPACE key to delete the preceding text--After the text input is complete, press the"ESC"key to switch to command mode. --In order to save the input content, enter in command mode"W <filename>", writes the contents of the text area input to the file. Note that you can save the file name without adding--Enter in command line mode": Q"and press ENTER to exit VI and return to the command prompt. --cannot be used directly after a file has been modified": Q"Command exits, you must use the": q!"command does not save file forced exit--": Wq"means Save and Exit VI

use VI to edit an existing document -- follow the VI command followed by the file name and press Enter -- because the path is not specified, the VI program looks for the filename in the default path (that is, the current directory).  The user can also specify a path for it. If the file does not exist, a new file is created at this time  -For example: Vi/home/bird/a.txt

vi undo Function -users can undo the last operation by pressing ENTER after entering ": U" in command mode . -- in VI, the Undo function is removed from the last disk to the current input, so undo can revert to the most original state,  but at this time the user cannot use ": Q" The command exits VI because the user has modified the contents of the buffer at this time.  If you do need to exit the VI program, you can use it in command mode " : q! ".

VI Delete Function -- in VI input mode, the user can use BACKSPACE (BACKSPACE) to delete the contents of the front of the cursor,  you can also use the DELETE key to delete the current character. In addition, a few keys are available in the VI command mode to delete a character or  to delete the "x Key "for the entire line: Delete the character that the current cursor is in.   " D-Key double-click " : Delete the line  where the cursor is located " R Key ": Modifies the character that the cursor contains

 . bash_profile file The Linux system does not look for executables in the current directory by default when executing executable programs, so executing a.out must specify the path and file--"./a.out", if you need to modify the Linux default settings, you need to find hidden files in the current home directory. Bash_profile, modify the Path property under the file with the VI editor, modify it to path= $PATH: $HOME/bin:. (Append after the original string":."), perform"Wq"Save the command, the configuration file does not take effect, and you need to execute the command again". . Bash_profile " , the configuration file takes effect at this time. The Path property means locating the paths of the files, and in Linux, finding the path between files with ":" To splitFor example"$PATH: $HOME/bin"Indicates that the system will first"$PATH"find the executable file under the path, and then"$HOME/bin"Locate the executable file. We append":."Indicates that the system will have more than one lookup path."."represents the current directory . Bash_profile Each user has one, and each user does not affect each other. 

Linux Utility VI

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.