"Vim little" vim's efficient movement

Source: Internet
Author: User

I still recommend all new vim friends first go to use vimtutor practice, and then go to see Vim's help document, write very carefully, and can immediately combat, effective quickly, many of the following are the examples of VIM help document, I feel very good, took out.


The reason why vim is efficient is because it has a high-efficiency mobile mechanism, as a learning vim, you can say this part you have to see, which can greatly reduce the number of keystrokes moved within the article, and out of the binding of the mouse, so that the hands do not have to leave the keyboard operation.


First, the basic movement of VIM


The basic operation of VIM is nothing but the upper (j) (K) Left (h) Right (L), this people are very familiar with, of course, the keyboard can be used around the top and bottom, but believe me, when you use it yourself this, you will not be able to leave it

JH L K

All of Vim's instructions can be added to a number, indicating the number of executions, i.e., the move command also supports:

10h     left 10 grid 20j move      up 20 rows

Second, the lateral special movement


The efficiency of VIM is formally reflected here:


1. Mobile ☆☆☆☆

0 move to Line first character ^ move to line first non-whitespace character $ move to line last character  ^         <------------    ... This was a line with example text    <-----------------   --------------->        0                        $ (here "...") Represents a white space character)


The above command is more important, in addition, if your text area is displayed relatively small, a row will be folded into a few lines, you may use the following command, the following command is all based on the screen instead of the actual line

G0 to the first character of the screen line (when the row wraps around and "0") g^ to the first non-whitespace character in the screen line (different when the line wraps around and "^") g$ to the last character of the screen line (different when the line wraps around and "$") GM to the screen line

2, Word Mobile ☆

W jumps to the beginning of the next word B jumps forward to the beginning of the last word e jumps to the next word ending GE jumps forward to the last word ending b b   b    2b      b &l t;----<--<-<---------<---this was a line with example text--->-->->---------------------          ;    W W 3w Example text ~ <-<-------->----> GE ge E E

Similarly, there are several other commands in this, the upper case of the above command, the skipped units are all strings separated by whitespace characters, which is very good to remember.

W jumps to the next string (separated by a blank character) B jumps to the last string (separated by a blank character) E       jumps to the end of the next string (separated by a blank character) GE      jumps forward to the last string ending


3. Find Mobile ☆☆☆

F   down find where a letter appears F         up find where a letter appears T           down find where a letter appears T         Find out where a letter appears before                      &N Bsp    Fh                     <---------------------&nbsp ;    to err is human. To really foul up need a computer.          -------->------------------->  & nbsp              FH         fy      to err are human.  To really foul up need a computer.                     <------------             ---------------->                        &NBS P      th                   &NBSP;TN 

Here is a hint, here can be used ';  ' Repeat, for example: Press FE, jump to err E, press again;  , jump to really e, press again; Jump to Need's E

4. Matching Mobile ☆☆☆☆

The match movement is used very much in the code block, and the efficiency is particularly high, with this command can easily jump in (), {} [], it helps you find the matching parentheses, convenient very

% jumps to matching parentheses     (This command can also be applied to [] and {}.                                (can be defined with ' matchpairs ' option)) % <----->if (A = = (b * c)/d) ~   <---------------->    %

Note: The cursor is not on a useful character, "%" will first find a forward lookup, and then press once will move to its match (for example, below the cursor at =, the first match is (b * c) The opening parenthesis, and then its closing parenthesis

if (A = = (b * c)/d) ~ +--->--->   %

Third, vertical special movement


1. Global Jump ☆☆☆☆

GG Jump to          file the first G            jump to the end of the file Ng         jump to a specific N line (code debugging Common) N% jump to approximately N% position

2. Moving ☆☆☆ in the field of vision

H jump to the          top of the field of view M jump into the field of view in the middle L jump into the field below     +-------------------------------+h-->| text sample text    | | Sample Text    | | text sample text |    | sample text    | M-->| Text sample Text | |    sample Text    | | text sample text |    | sample text    | L-->| Text sample text    |+-------------------------------+

Iv. Additional: Other operations


1. Rolling screen

Scrolling is mainly to read the document useful, have to roll half a screen, a screen, a line (this does not say, the meaning is not big)


Ctrl-u        scroll up half screen, text under the move upctrl-d scroll down half screen, text on the move Downctrl-b backward scroll one screen, text move backwardctrl-f forward scroll one screen, text on Mobile Forward

2. Move the cursor without scrolling

A common problem with moving is that when you move down with "J", your cursor will be at the bottom of the screen, and you may want the line of the cursor to be in the middle of the screen. This can be achieved through the "ZZ" command.

The ZZ cursor moves to the middle of the screen, the ZT cursor moves to the top of the screen (top) ZB the cursor moves to the bottom of the screen (bottom) +------------------+ +----------------- -+| Some text | |   some text    | | Some text   | | Some text    | | Some text   | | Some text    | | Some text   |
   zz-->| Line with cursor | | Some text | |   some text    | | Some text   | | Some text    | | line with CURSOR |    | Some text |+--------- ---------+ +------------------+


"Vim little" vim's efficient movement

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.