VIM cursor Movement

Source: Internet
Author: User

Recently full conversion development to Mac OS, with Macvim as IDE. Record some vim basic operations to your own memo.

This is said in Common-mode (C-mode, in the Vim aka Normal-mode, is just into vim, can not enter the text of the state) under the movement, the original VI can only move the cursor in the C-mode, In Insert-mode only the input of the text, not the movement of the cursor. Of course, Vim and Elvis's arrow keys are movable freely in either mode.

Basic cursor Movement

H Backspace   or arrow keys.
J Enter   or + (to Shift   key), or the arrow keys.
K shift   keys).
l right, or Space   or arrow keys.
ctrl+f i.e. Pa Gedown   Flip page (Forward, forward, next page).
crtl+b i.e. Pa Geup   Flip page (Backward, back, page up).



Similarly, for example, 20h, the cursor moves to the left 20 characters, 20J, the cursor moves down 20 characters;

Using HJKL
The key is moved so that the hand does not have to leave the typing area (the central part of the keyboard) to speed up the typing, if you are not accustomed to, then use the arrow keys! In fact, once used, the efficiency of editorial work
will be very helpful, and there are many workstations VI can only use HJKL mobile, so if possible, try to familiarize yourself with the HJKL cursor movement.

Backspace and Space are moved by the line at the beginning or end of the line, but the direction key or HL key moves at the beginning or end of the line when you continue to press and do not fold the line. The feature of the jog line is the expansion of the Vim , and Elvis does not have this function.

JK and moving the cursor up and down with the arrow keys will try to keep it in the same field. With the enter,+,-move up and down, the cursor moves to the first non-whitespace character on the top (bottom) line.

It seems to be a bit complicated, you can use the arrow keys to move simply understand! When you fall in love with the Vim then pay attention to it.

Advanced Cursor Movement

0 is the number word 0 instead of the English letter O. Or the Home key to move to the beginning of the line (with blank characters).
^ Move to the first non-whitespace character at the beginning of the line, notice that you want the Shift key.
$ Move to end of line, or end key. You want the Shift key.
G Move to the end of the document (the first non-whitespace character at the last line of the full text)
Gg Move to the top of the file (the first non-whitespace character in the first line of the full text).


In the rule expression (regular expression), ^ is the beginning of the match, and $ is the end of the matching line.

GG is an expansion of the Vim , which can be moved to the top of the file (the number 1 is not English text L) in Elvis or the original VI. The original meaning of G is Goto, which moves to the beginning of the specified number of lines, and if no number is specified, the default is the last row.

W Move to the beginning of a word (word). Of course, it means the English word.
W Ditto, but some punctuation marks are ignored.
E Move to the end of the next word.
E Ditto, but some punctuation marks are ignored.
B Move to the beginning of the previous word.
B Ditto, but some punctuation marks are ignored.
H Move to the first non-whitespace character at the top of the screen.
M Move to the first non-whitespace character in the middle of the screen.
L Move to the first non-whitespace character at the bottom of the screen. This and PageDown,PageUp not the same, the text content is not moved, but the cursor is moving only.
N| Move to nth character (column). Note that you use the Shift key. n is from the beginning.
: N Moves to the beginning of the nth line. or NG.

Special Mobile

) Move to the top of the next sentence (sentence).
( Move to the top of the previous sentence (sentence). Sentence (sentence) is with. ! ? to a grid.
} Move to the top of the next paragraph (paragraph).
{ Move to the top of the previous paragraph (paragraph). Paragraph (paragraph) is a blank behavior area.
% This is the match {},[], (), for example, the cursor on {Just press%, will run to match the}.

VIM cursor Movement

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.