Linux vim, vi editor basics, linuxvimvi Editor

Source: Internet
Author: User

Linux vim, vi editor basics, linuxvimvi Editor

I didn't know why I had to learn vim and vi editors before. I just heard that this is important to linux.

First, let's explain why I want to learn this editor and understand my book.

The important work of the system administrator is to participate in and set the configuration files of some important software. Therefore, you must learn at least one text editor on the command line interface. A set of text editors on all linux distributions are vi, and many software uses vi as their editing interfaces by default. Vim is the advanced version of vi. vi is an old-fashioned text processor. vim can not only display text content in different colors, but also implement programming functions such as shell scripts and c, vim can be considered as a program editor. Although there is also nano that can be used for text editing, other versions of the system may not, but there must be vi.

Vi usage:

Vi has three modes: general mode, edit mode, and command line mode.

1. General mode: open a file in vi and directly enter general mode.

2. editing mode: In normal mode, the file content cannot be edited. Press "I, I, o, O, a, A, r, r. To return to normal mode, Press ESC.

3. Command Line Mode: In normal mode, enter ":,/,? "Any one of them can move the cursor to the bottom line. In this mode, you can search for data, read, save, replace a large number of characters, and leave vi, operations such as displaying row numbers are completed in this mode.

Only the normal mode and the edit mode and the command line mode of vim can be switched. The edit mode and the command line mode cannot be switched.

The following are the buttons that I think need to be clarified:

: W writes the edited data to the hard disk file;

: W! If the file attribute is read-only, the file is forcibly written. However, whether or not the write operation can be performed depends on your own permissions.

: Q exit vi

: Q! If you have modified files and do not want to store them, use! Force exit without saving files

: Wq save and exit

: Wq! If your file cannot be written, for example, a read-only file, if you use "wq" after editing, the system will prompt that it is a read-only file. In this case, you can use "wq! To force write and save.




How to access the VI editor of LINUX?

VI is a notepad equivalent to the windows operating system.
For example, if you want to create a Hello. c file, perform the following operations:
Vi Hello. c (Press enter and start editing. To exit Press ESC, enter the intermediate mode, and press Colon: followed by the command)
: Wq (save and Exit)
: Q! (Exit and do not save)

How to access the VI editor of LINUX?

VI is a notepad equivalent to the windows operating system.
For example, if you want to create a Hello. c file, perform the following operations:
Vi Hello. c (Press enter and start editing. To exit Press ESC, enter the intermediate mode, and press Colon: followed by the command)
: Wq (save and Exit)
: Q! (Exit and do not save)

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.