Vim (1)

Source: Internet
Author: User

Vim is a simple and powerful text editor that can perform complex operations in a simple way. Vim (http://www.vim.org/) is an open source software that provides multi-platform versions on Windows, Linux, and MACOs. Vim on MACOs is called macvim (http://code.google.com/p/macvim ).

Recently, I began to fall in love with vim, like its operation mode, and like it very green. Let's share your learning experience.

I. Mode

The biggest difference between vim and other text editors is the concept of mode. Vim defines three modes: Normal, insert, and visual. Vim uses the division of different modes. Different operations belong to different modes. That is to say, an operation can only happen in a certain mode, which simplifies the operation to some extent. The concept of mode may be a bit difficult for people who are new to VIM, but once they are familiar with it, I promise you will like it and gradually become vimmer. The following describes the specific definitions of the three modes:

  • Normal Mode: the default mode of VIM. In this mode, run the command.
  • Insert mode: insert/write text in this mode.
  • Visual mode: In this mode, you can select a text area and execute commands or edit operations on the text in the area.

Switching between different modes is very simple. From normal to insert, you only need to press I or I, while from back to normal, you only need to press <ESC>. From normal to visual, you only need to press V or V, and then to return to normal, you only need to press <ESC>. Of course Vim also provides more ways to switch between modes, see, picture from a byte of VIM (http://www.swaroopch.com/notes/Vim ).

2. Drop the mouse-move the cursor

If you work on VIM, You can discard the mouse and use only the keyboard to complete all the work, because Vim provides a variety of ways to move the cursor using the keyboard. Let's take a look at several of them. The operations involved are completed in normal mode.

  • Upper left and upper right: H, JK, and L respectively. If you want to move multiple steps at a time, you only need to add a number before the corresponding command, for example, move two steps to the left after two hours.
  • Start and end: Jump to the last line by G, and jump to the first line by 1g. Add a number to the front to jump to the corresponding row, for example, 50 GB to 50th rows.

Cool or cool? The following is more cool!

  • Jump to the next word: Press W. If you want to return the previous position, press B. Similarly, to move multiple words, you only need to specify the digit prefix.
  • Jump to the next sentence: Press), and press (return the previous position.
  • Jump to the next section: Press}. Similarly, press {to return the previous position.
  • SKIP: press Ctrl-O to the previous position, and press Ctrl-I to the next position.
  • Mark position: Use Ma to mark a position in a piece of text as a, press 'a to jump to the row where the position is located, and press 'a to jump to the specific location where Mark A is located. The available positions are marked as a-Za-Z, 52 in total.

Iii. Learn help

There are a lot of operations and commands in Vim, and it is impossible to get them all down. We need to turn to Vim's built-in: Help, such as: help various-motions. Or you can go to Google or stackoverflow to ask a question.

References:

1. http://www.vim.org/

2. http://www.swaroopch.com/notes/Vim

3. http://code.google.com/p/macvim/

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.