10 tips on using the vim Editor (1)

Source: Internet
Author: User

BKJIA exclusive Article] Vim is a text editor similar to Vi, but many new features are added on the basis of Vi. Vim is generally regarded as the best one in the class Vi editor. Vim currently has Unix and Windows versions. Although vim has improved a lot compared with vi, it will still be difficult to use for the first time. I do not know how to operate it, therefore, to learn vim, you must first pass the 2-Level Test. In this article, senior system administrators will share with you their experience in using vim, and at the end of this article, we will attach a list of common vim commands.

The first step is to understand vim's design philosophy. At the beginning of vim's design, the entire text editing was completed with a keyboard instead of a mouse. Almost every key on the keyboard has a fixed usage, the producer of vim wants the user to complete most of the editing work in the normal mode, that is, the command mode. This mode is designed as the default mode. Beginners can enable vim, if you enter words directly, the results will be messy, because vim understands the words you enter as commands.

The second is the command line. vim has hundreds of commands for editing. If you are familiar with vim commands, the editing speed is indeed much faster than that of the mouse, but it is also difficult to remember them all. The best way to remember them is to practice a lot. vim is indeed used in daily text editing, and don't give up when encountering problems, instead, you can find a solution. Every time you solve a problem, your vim skills will increase to a level.

Experience of senior administrators

1. vim in FreeBSD is different from that in Linux. We recommend that you optimize it for different users. vimrc files, my current habit is to carry two optimization files with me. cshrc ,. vimrc, Which machine has my account, I will directly import it to the/home/andrewy account of the machine, so that it can be used easily;

II. The usage in the following table only meets the basic work of System Administrator. If you are a leper Member, we strongly recommend that you continue to study its advanced syntax, especially as the Devoleper of PHP and JAVA, editing program code with vim is not a problem;

3. If you are dealing with a lot of buddies on the graphic interface, you can download a gvim file to learn and work;

4. While deepening vim's learning, we also suggest strengthening sed's understanding and learning, and using vim + sed as much as possible to complete all daily editing work;

5. Try to use h, j, k, and l to complete the work on the left, bottom, and right. This is much more efficient than using the keyboard's arrow keys, but this is a problem that everyone can easily ignore, some unix machines do not support direction keys;

Vi. vim is not just an editor, but you can also use it to view the server configuration file (. conf), php (. php) file and shell (. sh) file. If you are familiar with it, you can also use it to view the log file. Remember not to save and exit;

7. Here we only introduce two useful plug-ins (in fact, I only use these two) taglist and ctags. Those who have used eclipse May be amazed at the function, variable, etc. in the program by pressing ctrl to automatically jump to its definition. Vim can also implement this function, ctags is used;

8. Assist Excel and other systems to process data, mainly using regular expression replacement and column mode. Replace 2006-6-30 with 2006.6.30 or 2006.6.30;

9. gvim, which I currently use, is mainly used to edit shell files and process text files. It feels very convenient. vim can also be used to edit C files;

10. My colleague used gvim in windows xp to read txtnovels, which looks good. I tried to use gvim to read the txt of those things of the Ming Dynasty on my work machine windows 2003 yesterday, yes.

BKJIA exclusive special article reprinted please indicate the author and source]

The following is a list of commonly used Vim commands for your reference.


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.