One week starter VIM

Source: Internet
Author: User
Tags save file

Objective

All said that the use of VIM, the programming experience feel silky, but the starting slope is indeed a bit steep, always daunting.

I have previously tried vim more than two times, each time because of confusion of its various modes, a variety of key commands, and use up the total stumbling, each time insisted not more than one afternoon to give up.

But every time to visit some technical community, always see the way the great God inadvertently said a vim, and always feel so powerful things, do not experience, it is regrettable, the heart and itch.

In combination with the current situation:

    1. Each IDE's shortcut keys are always CTRL, ALT, shift plus other key combinations, key frequency distribution uneven, use more total feel pinky some hair
    2. Unable to leave the mouse, can not form a smooth workflow, each encoding is working hard, but to do some adjustment, the hands have to stop, the right hand off the keyboard, to hold the mouse, watching the cursor movement, the last point, deep feeling very uncomfortable sense of fragmentation

Here are the main reasons why I feel I have to experience vim:

    1. I heard that vim itself is very flexible editor, all kinds of powerful functions can be customized out.
    2. In addition, the use of vim plugin + modern editor, you can use the VIM keyboard flow operation seamlessly switch to the various now editor, will not vim, in exchange for an editor to re-remember its shortcut keys, so it seems that vim although the previous experience may be more painful, but learned that may once and for all, combined, The time to remember shortcuts should be less than the non-use of vim.
    3. Vim's keyboard flow can not only be used in the editor, based on the concept of the development of various plug-ins, but also in the browser, command line and other places to use, most of the situation basically can abandon the mouse, which for the love of keyboard operation of me is really tempting

So, I decided to start again, fortunately this time finally persisted, recorded this experience.

First I switch to Google search learning resources, and then found something very fun and useful things, such as some sites to learn vim into a game, let you in the game using VIM command operation, this blog list of learning vim some good site.

Finally I chose Vim Genius this website as the study position, it divides vim commonly used several commands to divide several levels, lets you each one to learn, after each learning a level lets you use the keyboard to enter the command which the study commands, each command will repeat several times, ensures that you can remember, And can not skip and can not arbitrarily select the following levels.

My way of learning is this:

    1. Start by using Vim genius to learn a level and complete the level exercises, and then record the commands you learned.
    2. While learning to record some of the rules of the command, in fact, the vim of the keys set is regular, find out the rules, can help us quickly remember, and can extrapolate. If uppercase indicates an entire row or a reverse direction, two repeating lowercase indicates an entire row operation, etc.
    3. Do not rush, not a day to finish the Vim Genius, I think if not solid to do the above practice and record, that refreshed estimate also immediately forget, so I only brush two levels per day, every morning and evening after the meal brush once, so a total of 7 levels, with three or four days to finish the brush
    4. After the vim genius after the actual combat, I use idea+ideavim插件 as a combat position, first of all, start with the requirements do not high, first learned the most basic operation, can be deleted and modified, copy paste can, do not think of vim as the God to save you, but first to use Vim as an ordinary editor
    5. Learned the basic operation, encountered still not easy to check the relevant commands can, slowly progress

Using the above method, first in the Vim genius brush three or four days of basic commands, and then bite the teeth to stick to the actual combat three or four days, a week end, at this time using vim, at least to achieve the efficiency like with Windows Notepad, is a basic introduction, and then slowly learn advanced features faster.

Look back. Vim is no longer a high mountain from which to begin, but a smooth slope to see a path through

In the end, I was told the order of my record and the rule of summary, the wrong welcome pointed out.

    • Note: Use - number as a delimiter for interpretation and command
Law
    • Uppercase indicates the operation of the whole row or the opposite direction
    • Two repeating lowercase indicates an entire row operation
    • The quantity is placed in front of the command unit to complete the bulk operation: Each individual command can be done, can be called the command unit, such as the unit of a single word, DD units for one line, you can add a number in front of the command, so that the batch operation, such as 3w, 2dd,d2w, where d2w, the number 2 is W, Indicates that the action Unit is W (word) and the action is D, so that 2 words are deleted
    • Select Word: Select from the cursor position to the end of the word, not from the first character of the word
    • ^ denotes the beginning of a line character, and $ denotes the trailing character
    • L means backwards (last), h means forward (head)
    • W means save (write) and Word (word)
    • X means close, cut
    • W means save, Word
    • G means jump
    • C means change
    • P means paste (paste)
    • D means cut, delete (delete)
    • R = Replacement (replace)
    • E means edit or end (end)

Vim Document Special key tag (key-notation)

    • <CR>: OK key
    • <C-大小写字符>: Ctrl + corresponding characters
Mode
  • Back to normal mode-esc
  • into the command-line mode (command-line modes)-:
  • In replacement mode (replace mode)-R, which is equivalent to pressing the INSERT key under normal editing
  • into visual mode-----open this mode for easy selection
  • into visual mode and select the word under the cursor-VW
  • Enter visual mode to select words under the cursor and delete-vwd or vwx

    File
  • Closed file-:q
  • Closed files but not saved-:q!
  • Save File-:w
  • Close file and save-:x or: Wq or: ZZ
  • Save File as Play.rb-:w play.rb
  • Into the file Hat.rb-:r hat.rb

    Input
  • Before the cursor input-I
  • Input-I at beginning of line
  • After cursor, type-a
  • Enter-A after the end of the line
  • Add a new row below-O
  • Add a new row above-O

    Jump
  • Under the left and right-KJHL
  • To the first character of the next word-W
  • After jumping to the 3rd word before -3w
  • Before jumping to the first character of the word-B
  • After jumping to the end of the word-E
  • After jumping to the 3rd word -3e
  • To the last word end character-ge
  • To the last character of the current line-$
  • To the first character of the current line-^
  • To the beginning of the line-0
  • To line 50th -50g or: 50
  • To the beginning of the last line-G
  • To the beginning of the first line-gg
  • To a matching closing parenthesis-%
  • To the last cursor position-ctrl+o
  • To the next cursor position-ctrl+i
  • Turn one screen (forward)-ctrl+f
  • Turn one screen (back)-ctrl+b
  • Turn half screen (down)-ctrl+d
  • Flip Half screen (UP)-ctrl+u
  • Scroll down (extra)-ctrl+e
  • Scroll up-ctrl+y
  • The current cursor position is centered vertically-zs

    Undo Redo
  • Pin-U
  • Line undo-U
  • Do-ctrl+r

    Find
  • Look under "Waldo"-/waldo
  • Find "Carmen" on the-?carmen
  • To next find result-n
  • To the previous find result-n
  • Ignore case-:set IC or: Set ignorecase
  • The lookup is case-sensitive-:set noic or: Set Noignorecase

    Change replacement
  • Change the character under the cursor-R
  • Change word-cw, i.e. delete from cursor to end of Word and enter edit mode
  • After changing 3 words-c3w
  • After changing 3 characters-c3l or 3s
  • 3 characters before changing-C3H
  • Change to end of line-C or C $
  • The current line replaces Bad-:%s/bad/good with good
  • The whole file with bye question number hi-:%s/hi/bye/g
  • The entire file replaces x with Y and the change prompt-:%s/x/y/gc, highlighting all replaceable locations and choosing whether or not to confirm the replacement

    Shear
  • After clipping 3 characters -3x or d3l
  • Pre-cut 3 characters -3x or d3h
  • After cutting 2 words-d2w
  • Cut selection in Visual mode-D
  • Cut to end of line-D or d&
  • Cut the whole line-DD
  • Cut two lines of -2DD

    Copy and paste
  • Making word-yw
  • Select the words in the visual mode and copy the-vwy
  • Full line-yy
  • System to the beginning-y0
  • System to the end of the line-y$
  • Paste to the cursor after-p
  • Paste before the cursor-p

    Register
  • Mode: "Register name + Operation Command"
  • See Help-:help Register
  • See all register Contents-:reg
  • Name (default) register-"", storing the most recent content
  • Word register-"0~" 9, storing the most recent 2~9 times content
  • Name Register-"a~" Z, can be selected by name to deposit the contents of the specified register
  • Select and drag (System) Register-"*," +, "~, connect the system Pasteboard
  • Word to a register-"Ayw
  • Paste the contents of a register-"AP
  • Paste the contents of the system board-"+p
  • command-line mode pastes the contents of the default register-ctrl+r+ "
  • Command line mode paste the contents of the system Pasteboard-ctrl+r+*

    Code
  • Change, cut, and copy the contents of the paired characters that surround the cursor-ci+ the first character of the paired character
  • Change, cut, copy the contents (including pairing characters) between the paired characters that surround the cursor-ca+ the characters of the pairing character
  • Line left, right indent -3<<, 3>>
  • Left, right indent selected lines in graph mode-<, >

    Other
  • Run the command with the shell Ls-:!ls
  • Open a new file Sun.rb-:e sun.rb
  • See Command W Help-:help W
  • Normal model inversion cursor under character case-~
  • Convert to uppercase-U in view mode, convert to lowercase-u
  • At least 5 lines above the cursor are visible-:set scrolloff=5, which can be used to set the cursor vertically centered

One week starter VIM

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.