Vim Learning Guide

Source: Internet
Author: User
Tags expression engine

You want to learn vim as quickly as possible (the best editor you know ). This is my learning method: Start from the details and learn all the skills.

Vim $6 billion Editor

Excellent Design, strong and fast.

Learn vim and use it as your next text editor. As far as I know, there is no better editor than it. It is difficult to learn but surprisingly easy to use.

I suggest you follow the four steps below to learn Vim:

  1. Adaptation
  2. Comfortable
  3. Feeling good, strong, fast
  4. Advanced vim skills

At the end of this course, you will become a vim guru.

But before we start, let us know. At the beginning, learning vim would be a bit painful. It took a lot of time, just like playing an instrument. Don't expect to be able to use it well within three days like other editors. In fact, it must take two weeks instead of three days.

Recommended reading:

  • Quick learn Vi Editor
  • Powerful Vim Editor
  • Build a Vim Development Environment on CentOS 6.2
  • Vim 7.4a released, a new and faster Regular Expression Engine
  • Install the highlighted Vim editing tool in CentOS 5.4
  • Vim tips: C language settings
  • Set the Vim row number in Ubuntu
Level 1-Adaptation
  1. Install vim
  2. Run vim
  3. Do nothing. Read it!

In the standard editor, you only need to input something on the keyboard to write something to the screen. This is not the case in Vim. Vim inNormalMode, let's goInsertMode, type the character I.

You should feel better. If you can enter it in the Standard editor, you only need to press ESC to return to normal mode.

Now you know how to insert andNormalSwitch between modes.NormalCommands to be remembered in the Mode:

 
 
  • I →InsertMode. Press ESC to returnNormalMode
  • X → Delete the character of the cursor
  • : Wq → save and quit (: w save,: q quit)
  • Dd → Delete (copy) The current row
  • P → Paste

Recommended:

  • Hjkl (highly recommended) → moving the basic cursor →), hj moving by row.
  • : Help <command> → show help about <command>. You can use help without <command> for general help.

There are only five commands. You only need to master these commands at the beginning. When you get used to these commands (it may take about one day or more lines), you can go to the second level.

But first, let's take a look back.NormalMode. In the standard editor, you need to press ctrl-c to copy the file ). In fact, when you press ctrl, the meaning of all the buttons changes. In vimNormalMode is like using the editor when the ctrl key is automatically pressed.

Final supplement:

  • I used <C-λ> instead of Ctrl-λ.
  • The command is followed by a carriage return. For example, if I write q, I mean q <enter>
Level 2-Great

As you know, commands are determined by requirements. It's time to learn more commands. The following are my suggestions:

  1. Insert mode variant command:

       
       
    • A → Insert after the cursor
    • O → Insert a new row after the current row
    • O → Insert a new row before the current row
    • Cw → replace from cursor to word end
  2. Basic mobile commands

       
       
    • 0 → jump to the first column
    • ^ → Jump to the first non-empty character in the row
    • $ → Jump to the end of the row
    • G _ → jump to the last non-null character of the row
    • /Pattern → search for pattern
  3. Copy/paste

       
       
    • P → paste it before the current position. Remember that p is pasted before the current position.
    • Yy → copy the current row, which is easier than dd and P commands.
  4. Cancel/restore

       
       
    • U→ cancel
    • <C-r> → restore
  5. Load/save/exit/modify file (cache)

       
       
    • : E <file path> → open
    • : W → save
    • : Saveas <file path> → save to this file
    • : X, ZZ or: wq → save and exit (: x, if possible, only save)
    • : Q! → Exit but not save. Use: qa !, Even if there are modified items in the cache, the system exits.
    • : Bn (comparison: bp) → display the cache of the next (previous) File

Take some time to learn all these commands. Once completed, you should be able to complete everything in the editor like other. Maybe you may feel a little clumsy. But as I enter the next layer, you will find out why vim deserves your extra efforts.

Level 3-better, stronger, and faster

Congratulations! Now we can start this interesting thing. At the third level, we will only discuss commands, which are compatible with the old vi editor.

Better

Let's see how vim helps you repeat things.

1 .. → (point) You can repeat the last command,

2. N <command> repeats the command N times.

In some examples, open a file and write the following content:

• 2dd→ will delete 2 lines • 3p→ will paste the text 3 times • 100idesu [ESC]→ will write “desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu desu” •.→ Just after the last command will write again the 100 “desu”. •3.→ Will write 3 “desu” (and not 300, how clever).
  • 1
  • 2
  • 3
  • 4
  • Next Page

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.