Vim editor learning notes and vim learning notes

Source: Internet
Author: User

Vim editor learning notes and vim learning notes

There are many text editors that can run in Linux. Different Linux distributions will certainly have built-in Vi editors, and other editors may not have built-in ones. You need to install them on your own. Therefore, you must learn how to use Vi in a new Linux environment. The Vim editor is an upgraded version of the Vi editor. It is more powerful than Vi and is compatible with Vi operations. So I learned the Vim editor directly. (This article only records my study notes and will be constantly supplemented and modified. please correct me if there is anything wrong)

The Vim editor has three modes: Command mode, insert mode, and command line mode. When Vim is enabled, enter the command mode. In this mode, you can move, delete, and copy the cursor"I, I, a, A, o, O, r, R"The eight commands enter the insert mode. In this mode, the text content is inserted and modified. Press ESC to exit the command mode.":,/,?"Enter the command line mode. In this mode, perform operations such as searching, replacing, saving, and releasing, and reading files. Press ESC to exit the command mode. The insert mode and command line mode cannot switch between each other. You can only switch out of the command mode.

1. Open, close, and save the file

1,Vim filename [...]

Enter the above command in Bash to open the file. Vim can be followed by multiple file names to open multiple files at the same time. If the filename file does not exist, a file named filename is created.

2. Press ":" to enter the command line mode.Q,W,!Three commands to save the file and exit.

: Q# Do not save the exit File

: Q!# Force exit (!Is forced to exit, does not require user confirmation)

: W# Saving files does not exit

: Wq# Save and exit

: Wq newfilename# Save As newfilename and exit

: N1, n2 w newfilename# Save the content from line n1 to line n2 of the file as a new file named newfilename

3. In command line mode,R,E"Two commands to open the new file.

: R filename# Append the content of filename to the end of the file being edited

: E filename# If no file is specified when you open the Vim editor, you can use this command to open the filename file for editing.

(To be continued)

 

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.