Shell Programming--vim Common commands

Source: Internet
Author: User

[Vim]
Operating mode switching:
Enter edit mode when I (insert), C (modify), O (another line) command is entered in normal mode, and press ESC to return to normal mode.
Enter a colon in normal mode (:) can enter command mode. After entering the command press ENTER, the command will automatically return to normal mode after execution.
Tip: If you are not sure which mode you are currently in, pressing ESC two times will return to normal mode.

Exit:
Q If the file is not modified, it will be returned directly to the shell, otherwise prompt to save the file.
Q! Forcibly exits without saving the modified content.
The Wq w command saves the file, and the Q command exits VI, which, together, saves and exits.
ZZ saves and exits, equivalent to Wq, but more convenient.
W file writes the contents of the current file
W! File writes the contents of the existing files to the existing
: Set Nonu does not display line numbers

To move the cursor:
To not affect the contents of the file, you must move the cursor under normal mode (press two ESC). Use the commands in the following table to move one character at a time:
Command description
K Move cursor up (move one line)
J Move Cursor Down (move one line)
H move the cursor to the left (move one character)
L MOVE the cursor to the right (move one character)

To edit a file:
You can edit the file by switching to edit mode. There are a number of commands that can be switched from normal to edit mode, as shown below:
Command description
I insert text before the current cursor position
I insert text at the beginning of the current line
A inserts text after the current cursor position
A inserts text at the end of the current line
o Create a row below the current position
O Create a row above the current position

Delete character:
The following command allows you to delete a character or line from a file:
Command description
x Delete the characters under the current cursor
X Delete the characters in front of the cursor
DW deletes characters from the current cursor to the end of a word
d^ Delete characters from the current cursor to the beginning of the line
d$ Delete characters from the current cursor to the end of the line
D Delete the character from the current cursor to the end of the line
DD Delete the line where the current cursor is located

Buffer Operation Command:
Copy cursor line: Y/YY
Pastes the contents of the buffer into the following line of the cursor: p/p
Cut the current line: "CD #不要忘记"
Undo the last operation and press U again to restore the operation: U

To run the command:
Switch to command mode, and then enter! command to run the Linux command.
For example, before you save a file, if you want to see if the file exists, enter
:! Ls
You can list the files in the current directory.
Press any key to return to the VI editor.

Some tips:
Enter a colon (:) Enter command mode and press ESC two times to enter normal mode.
The meaning of the case of the command is not the same.
You must be in edit mode to enter content.

Shell Programming--vim Common commands

Related Article

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.