Skills in using the Vim editor in Linux (1)

Source: Internet
Author: User

Vim is the most commonly used editor in Linux. For example, configuration file changes and environment variable settings are basically completed in the vim editor. This is the most common tool for Linux system administrators. However, this tool is small, but it has a lot of practical tips. Some system administrators may not know. I will share these skills here. If you find them useful, you may wish to use them in your work.

1. Backup personalized configuration files.

The Vim text editor has many default settings. However, when the system administrator is familiar with this tool, the default settings may not meet their requirements. For this reason, the system administrator wants to perform some personalized settings like Word and other text processors, so that they can easily write configuration files and set environment variables. For example, the system administrator may redefine some key functions, create abbreviations, or set a specific environment. These personalized contents are stored in a file. In Linux, the file is stored in the user's home directory by default. Generally, the file name is vimrc. Note that this file is an invisible file. You must use the-a option to view the file. Some versions of shell may not have this file, so they cannot save personalized settings. In this case, you can copy the file from another version of the system. Generally, this file is common.

The file is automatically read when the vim editor is started. Over time, this file will gradually become a dedicated database of the system administrator. This file contains all the shortcut keys that the system administrator is familiar with and environment configurations that are frequently used by users. This is very important for system administrators. For this reason, the system administrator should often back up this file. In addition, if the system administrator often needs to move the Office, it is best to take this file with him. In this case, even if you change the working platform, the system administrator can easily create a familiar vim working environment by copying the file to the new platform. The file is stored in the user's directory. Therefore, this file will not affect the vim tools of other users on the operating platform. This feature is very useful in multi-user environments. For example, a database server and email server are deployed on a Linux server and maintained by different administrators. At this time, because the configuration file is stored in their respective user directories, as long as they use different user login names, this will not interfere with each other.

2. Cancel the error operation quickly.

When using vim in Linux, what should I do if I enter an incorrect parameter without knowing the value of the previous parameter? In other text editors, such as the Word text editor, you can undo it by undo or pressing CTRL + z to restore the data before modification (provided that it is not saved ). However, in the vim editor, you will find that this key combination does not work and there is no Undo button. Can this vim editor undo the wrong operation? Actually, it works in a different way than other editors.

When an error occurs during text editing by the system administrator, if a parameter is modified or the text that should not be deleted is deleted, you can modify the original content again. However, if you do not know the content before the modification, or the content of the incorrect modification is large, the system administrator can Press ESC or U to cancel the previous operation. If this operation is ineffective, you can use the ctrl + r key combination to restore the last incorrect operation. Note that the ctrl + z key combination does not work in the vim editor. If you use this key combination in the vim Editor, The ^ z symbol is displayed in the notebook. This key combination is not defined in the vim editor by default. Note that in the input mode, you must use the esc key to exit the input mode and then use the u key. Otherwise, when the system administrator uses the u key, it is treated as a normal key, which will enter the u character in the editor. Note that you need to exit the insert mode first.


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.