About Vim's class exercises

Source: Internet
Author: User

1. What is the difference between VI and VIM, and what is the relationship between them?

Vim is a text editor developed from VI and can be viewed as an upgraded version of VI. Vim's main function is completely compatible with the original VI, unlike VI, VI will not display color, and vim will be based on the contents of the file display different colors, easy to read and edit. and vim with code completion, compile and error jump and other convenient programming rich features, in the programmer is widely used. (Vim and Emacs are the favorite editors for Unix-like system users.) )


2. How do I view the current system vim version?

Vim--version


3. What do I do if I want to replace all "ABC" in the Document with "Def"? And how do you just replace the first "ABC" that appears in each line?

: 1, $s/abc/def/g

: 1, $s/abc/def


4. When searching for a keyword, what is the line of the keyword where the cursor is positioned? What do I do if I want to move from the current keyword to the next keyword? How do I move to the previous keyword?

You need to see when Vim enters the document, where the cursor is located, and the positioning keyword is based on where the cursor is located.

If using/searching for keywords, press ' n ' to move down, press SHIFT + N up, if used? Search keywords, and the former is just the opposite.


5. When you finish editing the document, press ESC to enter command mode and enter the command: x what happens?

Input command: X can also save the file and exit, a bit similar: WQ, but there is a difference between the two.

: x #写入文件并退出. The file modification time is not updated unless the file is modified and the file modification time is updated.

: Wq #强制性写入文件并退出. Force write even if the file is not modified, and update the file's modification time.


6. How to quickly move the cursor to the right or left 10 characters in normal mode?

Right: 10 spaces

Left: 10l


7. What does VIM + filename mean and what will happen to vim +10 filename?

Vim + after entering the document, navigate to the last line

Vim +10 After entering the document, the cursor is positioned to line 10th


8. After opening a document with Vim, I want the cursor to jump to line 20th, what do I do? How do I jump to the last line?

Jump To line 20, enter 20G

Last line, enter G


9. Vim when the document is opened, the default is not to display the line number, how do you let it display line number?

: Set Nu


After Vim opens the document, I want to replace the first ' ABC ' in line 20-50 with ' EFG ' How to do it? What if you want to replace all of them?

: 20,50S/ABC/EFG replaces only the first one

: 20,50s/abc/efg/g Replace All


One. Vim how to quickly delete the first 100 lines after opening a document?

First press ' GG ' to the first line, then enter 100d


When Vim opens a document, how do you copy a line and paste it below line 20th?

Navigate to the row you want to copy, enter yy, then enter 20G, and then enter P


About Vim's class exercises

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.