There’s a joke.

How to learn to swim quickly?

It’s just three steps: get to the river, kick in the water, stick it out of the way.

So how do you learn VIM quickly?

The default editor is set to Vim, delete all other editors and launch tomorrow.

Here are a series of steps to quickly use Vim with zero configuration and zero plug-in. With a little practice, you can quickly become proficient with Vim. He is the only one who knows.

A link to the original article can be found on Shan Yue’s blog

Fast moving

Fast mobility is the most important thing for Vim, more than anything else. It is also the basis for editing and modification.

  • Move up (k), down (j), left (h), right (L). Do not use the up, down, and left arrows. If you need to move several lines, add a number before the operation. For example, 10j represents moving ten rows down. By combining numbers with operations, that’s vim’s idea.

  • Reduce the left and right movement of the previous step, which is inefficient. Use B, B, w, w instead of B to refer to back a word. W means forward a word. B) back a WORD W means forward a WORD, a big WORD.

    Among them, the difference between Word and Word is illustrated with an example. Hello. World has three words (‘hello’, ‘.’, ‘world’) but only one word.

  • Use f, f, t, t for more subtle left-right movement control, f for find a character, quickly move to the next character, f for forward. Combine B and W to achieve fast left and right movement. T refers to tail a character, the character before the position of the next character, and t refers to the previous search.

  • Use 0, $to move the beginning and end of the line

  • Use % to move quickly to match characters such as open parenthesis to close parenthesis, open quotation mark to close quotation mark, most commonly used in encoding!

  • Use Ctrl-D, Ctrl-U to move up and down in a wide range ctrl-D move down half a page, Ctrl-U move up half a page.

    You can also use

    ,

    to move the entire page.

  • Use GG, G to move first and last lines

  • :128 Indicates a quick location to 128 lines. Currently, it is used only in debugging

  • Zz quickly positions the current cursor to the middle of the screen, ZB to the end of the screen, and ZT to the top of the screen

  • * Position the word under the current cursor and point to the next one, # point to the previous one

  • Gd is commonly used in encoding to locate the declaration position of the current variable and GF to the file pointed to by the current path.

  • Finally, if you make a mistake, use

    -o to return to the position above the cursor

The editor

Vim edits are in Insert Mode, and the above quick moves are in Normal Mode. Editing text requires first going into Insert Mode.

I, I, a, a, O, o go into Insert Mode.

I refers to insert text, which is edited before the cursor, and I refers to the beginning of the line. A refers to append text, which is edited after the cursor, and A refers to the end of the line. O refers to append text, which is edited on the line after the cursor, and O refers to edit on the line before the cursor.

Personal habits: I, A, O, O are used more than I and A.

Esc and

can exit Insert Mode.
[>

I prefer to use

because Esc is too far away, and Esc is prone to conflict with other hotkeys in some editors.
[>

Modify the

Delete can also be manually deleted by using the DELETE key in Insert Mode, but the efficiency is too low, it is recommended to delete in Normal Mode, just enter viM state is Normal Mode.

  • Using x(dl) to delete a particular character can combine x with the quick movement described above to delete a particular character under the cursor

    Put an L in brackets to indicate that x is short for DL.

    ddeleteIs the basis for all modification operations.dldlDelete the character to the right of the cursor.dhThe character to the left of the delete cursor, the basic form of all deletes, is the core idea of Vim.

  • Use daW to delete specific words

    Daw means to delete a word. Db, dw can also be used to delete words.

  • Use dt, df plus a specific character to delete the text before the character

  • Use di(, da(to delete text within specific symbols, such as parentheses and quotation marks

    Di (means delete in (, not delete parentheses. Da (means delete a(, will be deleted with parentheses. The same goes for di’, di” and so on, most commonly used in coding!

  • Use D (D $) to delete all text after this character

  • Delete the entire line using dd

  • Replace all d of the above operations with C, indicating that the deletion will enter editing mode

    C stands for change, meaning to delete, and like D, is the basic verb of vim

  • R plus a specific character indicates that a specific character is used instead of the original character

Files and multiple Windows

  • Use :Ex (Explore) to browse the directory

    Locate the file and press Enter to enter the specified file

  • Use :ls to list buffers

    Buffer list to save the most recently used files, the line has a label

  • Use :bn to access the most recently used file

    Bn refers to buffer next, the next buffer in the buffer list, that is, the last file used

  • Enter the file numbered N in the buffer list using :b[N]

    B 10 refers to buffer 10, which enters the buffer list, i.e. the file was used last time

  • Use: SBN, : VBN to open recently used files in a new window

    S means split, horizontal. V stands for vertical.

  • Use :on(ly) to keep only the current window

Basic operation

Basic operations refer to find, replace, undo, redo, copy, paste, save, etc

  • /{pattern} Searches for words or regular expressions to be searched. N goes down and n goes up.

  • : S /aa/bb/g substitute S stands for substitute, g stands for global substitute.

  • U undo U stands for undo, undo. Can be combined with a number for multiple undo.

  • The < Ctrl – r > redo

  • Yy copy the whole line y stands for yank, copy. By combining y with fast movement, you can use multiple cases of copying, such as copying the contents of parentheses, copying the contents of quotes.

    When copying, the current contents are put into a register, using :reg to view the register list.

  • P paste p means paste.

  • “*y Copies content to system clipboard

    The :reg will list the registers, “* the register represents the system clipboard (), so this is putting the contents on the system clipboard.

    If the list without the registers, vim does not support the system clipboard, also can use the command vim – version | grep clipboard.

  • “*p Paste the system clipboard content

configuration

For configuration, recommend Amix/VIMRC, which has over 14,000 stars on Github.

I also recommend my shfshanyue/vim-config configuration, which has plug-ins like Emmet and typescript that are great for front-end development.


Pay attention to the public number shanyuexixing, record my technical growth, welcome to exchange