Vim Vax Shortcut Key Encyclopedia _ Practical Skills

Source: Internet
Author: User
Tags lowercase

Efficient mobile

Outside of the insert mode

Basically, you should stay in the insert mode as little as possible, because Vim is like a "dumb" editor in the insert mode. Many beginners will stay in the insert mode because it is easy to use. But the strength of vim is in his command line mode! You'll find that after you get to know vim more and more, you'll spend less time using insert mode.

Using h,j,k,l

The first step in using Vim for efficient editing is to discard the use of arrow keys. With VIM, you don't have to move between the arrow keys and the letter keys frequently, which can save you a lot of time. When you are in command mode, you can use h,j,k,l to implement the function of left, bottom, top, RIGHT arrow respectively. You may need to get used to it at first, but once you get used to it, you'll find the efficiency of this operation.

As you edit your e-mail or other text with paragraphs, you may find that the arrow keys are different from what you expect, and sometimes you may skip a lot of rows at a time. This is because your paragraph in vim appears to be a large, long line. At this point you can type a G before pressing H,J,K or L, so vim will press the line above the screen as you wish to move it.

A valid move cursor within the current line

Many editors only provide simple commands to control the movement of the cursor (e.g. left, top, right, bottom, to start/end). VIM provides a lot of powerful commands to satisfy your desire to control your cursor. When the cursor moves from one point to another, the text between these two points (including these two points) is called "Cross", and the command here is called motion. (briefly, this important concept will be used later.)

Here are some of the common命令(motion):

FX: Moves the cursor to the next X at the current line. Obviously, X can be any letter, and you can use it to repeat your last F command.

TX: Similar to the above command, but is moved to the left of X position. (This is really useful)

FX: Similar to FX, but looking backwards.

W: The cursor moves one word forward.

B: The cursor moves one word backward.

0: Move the cursor to the current beginning of the line.

^: Moves the cursor to the first letter position of the current line.

$: Move the cursor to the end of the line.

): Move the cursor to the next sentence.

(: Move the cursor to the previous sentence.)

Effectively move the cursor throughout the file

Vim has a lot of commands that you can use to get where you want to go in the file. Here are some of the files inside 移动的命令 :

: Move down one screen.

: Move up one screen.

G: To the end of the file

NUMG: Moves the cursor to the specified line (num). (for example, 10G is to line 10th)

GG: To the top of the file

H: Move the cursor to the top of the screen

M: Move the cursor to the middle of the screen

L: Move the cursor to the bottom of the screen

*: Reads the string at the cursor and moves the cursor to where it appears again.

#: Similar to the above, but looking in the opposite direction.

/text: Searches the string text from the current cursor and arrives where text appears. You must use ENTER to start this search command. If you want to repeat the last search, press N.

? Text: Similar to the above, but in the opposite direction.

MA: Marks a bookmark at the position of the current cursor, named A. A book signature can only be a lowercase letter. You can't see the bookmark, but it's already there.

' A: to bookmark a. Note that this is not a single quote, it is generally located on the left side of 1 of most keyboards.

'.: To the place where you last edited the file. This command is useful, and you don't have to mark it yourself.

High-efficiency input

Automatic completion with keywords

VIM has a very nice keyword to complete the system automatically. This means that you can enter a part of a long word and then click a key, and then vim completes the long word input for you. For example: You have a variable named Iamalongandawkwardvarname somewhere in the code you write. Maybe you don't want to enter it in a single letter each time.

Using the Keyword AutoComplete feature, you only need to enter a few letters (such as Iamal), and then press (hold down CTRL, then press N) or. If Vim doesn't give you the word you want, basically press it until you're satisfied, and Vim will loop through the matching string it finds.

Smart into the Insert mode

Many beginners go into the insert mode with just I. This can, of course, go into the insert mode, but it's usually not as appropriate, because VIM provides a lot of commands to go into the insert mode. Here are some of the most common:

I: Inserts to the left of the current character

I: Inserts at the beginning of the current line

A: Inserts to the right of the current character

A: Inserts at the end of the current line

O: Inserts a new row below the current line

O: Inserts a new row above the current line

C{motion}: Deletes the characters spanned by the motion command and enters insert mode. For example: C $, this will remove the character from the cursor position to the end of the line and enter insert mode. Ct! , this deletes from the cursor position to the next exclamation mark (but not included), and then enters insert mode. The deleted characters are present inside the Clipboard and can be pasted again.

D{motion}: Similar to above, but not into insert mode.

Effectively move large segments of text

Using Visual Selection (visual selections) and the appropriate selection mode

Don't want the initial vi,vim to allow you to highlight (select) some text and to do the operation. There are three types of visual selection modes:

V: Select by character. Always use the pattern, so try it yourself.

V: Select by line. This is especially useful when you want to copy or move a lot of lines of text.

: Select by block. Very powerful, only in a very small number of editors to have such a function. You can select a rectangular block, and the text inside the rectangle will be highlighted.

Use the arrow keys and commands described above when selecting a mode (motion). For example, VWWW will highlight the three words in front of the cursor. VJJ will highlight the current row and the following two lines.

Cut and copy in Visual selection mode

Once you highlight a selection, you may want to do something:

D: Clip selected content to Clipboard.

Y: Copy selected content to Clipboard.

C: Clip selected content to clipboard and enter insert mode.

Cut and copy in non-visual selection mode

If you know exactly what you want to copy or cut, you don't need to go into visual selection mode at all. This will also save time:

D{motion}: Cuts the motion command across the characters to the Clipboard. For example, DW cuts a word and DFS cuts the characters from the current cursor to the next s to the Clipboard.

Y{motion}: Similar to above, but copy.

C{motion}: Similar to D{motion}, but finally into insert mode.

DD: Cut the current line.

YY: Copies the current line.

CC: Cut the current line and enter insert mode.

D: Cut from the cursor position to the end of the line to the Clipboard.

Y: Copies the current line.

C: Similar to D, and finally into insert mode.

X: Cut the current character to the Clipboard.

S: similar to X, but finally into insert mode.

Paste

Paste is simple, press p.

Using multiple clipboard

Many editors provide only one clipboard. Vim has a lot. The Clipboard is called a register (registers) inside VIM. You can list all the currently defined register names and their contents, and the command is ": Reg". It is best to use lowercase letters as the name of the register, because some of the capitalization is consumed by vim.

Use the registers command for double quotes ".

For example: We want to copy the current line to register K. You should press "Kyy." (You can also use V "Ky.) Why is this possible? Now the current line should already exist in register K until you copy something into register K. Now you can use the command "KP to paste the contents of the Register K to where you want it."

Avoid duplication

It's amazing. Command

Inside VI, enter. (decimal symbol), will repeat the previous command you have given. For example, your last command was ' DW ' (delete a word), vi will then delete a word.

Working with numbers

Using numbers is also one of the most powerful and time-saving features of Vim. A number can be used before a lot of Vim's commands, and this number will tell vim how many times this command needs to be executed. Like what:

3J will move the cursor down three lines.

10DD will delete 10 rows.

Y3 "will copy the content from the current cursor to the third occurrence of the quotation mark to the Clipboard.

Numbers are a very effective way to extend the scope of the motion command.

Record macros

Sometimes you will find yourself repeating the same sequence of actions in each paragraph or line of the article. Vim allows you to record a macro to fulfill your special needs.

Qregister: Record macro to register register, where register is any name of your register. QA, for example, will record and place the macro in register a.

Q: End the macro record.

@register: Use macros that exist register registers. For example, @a will use macros that exist in register a.

It's important to keep in mind that macros only record your series of keystrokes and execute them repeatedly. They are not magic. Because there are a lot of ways to accomplish this in vim, there are times when you have to carefully select commands to record your macros. Because they will be executed wherever you want to execute it.

Write code with VIM

Vim is an excellent editor for writing code because it has features that are specifically designed for programmers. Here are some of the common:

]p: Similar to the function of P, but it automatically adjusts the pasted text to fit the current code position. Try it!

%: Matching curly braces, square brackets, brackets, etc. At the top of a bracket, and then by%, the mouse will appear in the other half of the matching brackets.

>>: Indent All selected code

<<: Similar to above, but indented

GD: Gets to the definition of the function or variable at which the cursor is located.

K: Find the words in the man where the cursor is currently located.

Vim Find and replace summary

0,:g/null/d

Find the null row and erase

1, simple substitution expression

The substitution command can replace another word with one word in the full text:

:%s/four/4/g

The "%" range prefix indicates that replacements are performed in all rows. The last "G" tag represents all the matching points in the replacement row. If you are only working on the current line, you can simply remove the%

If you have a word like "thirtyfour", the above command will go wrong. In this case, the word will be replaced with "Thirty4″." To resolve this problem, use "\<" to specify the beginning of the matching word:

:%s/\

Obviously, this will make a mistake when dealing with "fourty". Use "\>" to solve this problem:

:%s/\/4/g

If you are coding, you may only want to replace the "four" in the annotation and keep the code in the. Because this is difficult to specify, you can add a "C" tag to the substitution command so that Vim prompts you before each replacement:

:%S/\/4/GC

2, remove the extra space

To remove the extra space after each line, you can execute the following command:

:%s/\s\+$//

The command indicates that the range is "%", so this will work on the entire file. The match pattern for the "substitute" command is

"\s\+$". This represents one or more (\+) spaces (\s) before the end of the line ($). The "to" section of the substitution command is empty: "//". This will delete those matching whitespace characters.

3, matching the pattern of repetition

The asterisk entry "*" stipulates that the item in front of it can be repeated any time. So:

/a*

Match "A", "AA", "AAA", and so on. But also matches "" (empty string), because 0 times also contains. The asterisk "*" applies only to the item immediately preceding it. So "ab*" matches "a", "AB", "ABB", "abbb", and so on. To repeat the entire string multiple times, the string must be composed of an item. The way to make an item is to precede it with "\ (", followed by "\)". So this command:

/\ (ab\) *

Match: "AB", "Abab", "Ababab", and so on. and also matches "".

To avoid matching empty strings, use "\+". This means that the previous item can be matched one or more times.

/ab\+

Match "AB", "ABB", "abbb", and so on. It does not match "a" followed by "B".

To match an optional option, use "\=". For example:

/folders\=

Match "folder" and "Folders".

4, specify the number of repetitions

To match a specific number of occurrences of an item, use a form such as "\{n,m}". where "n" and "M" are numbers. The item in front of it will be repeated "n" to "M" Times (|inclusive| contains "n" and "M"). For example:

/ab\{3,5}

Match "abbb", "abbbb" and "abbbbb".

When "n" is omitted, the default is zero. When "M" is omitted, the default is infinity. When ", M" is omitted, it means repeating exactly "n" Times. For example:

Pattern matching times

\{,4} 0,1,2,3 or 4

\{3,} 3,4,5, et cetera.

\{0,1} 0 or 1, with \=

\{0,} 0 or more, same *

\{1,} 1 or more, with \+

\{3} 3

5, multiple selection of a match

In a lookup mode, the "or" operator is "\|". For example:

/foo\|bar

This command matches "foo" or "bar". More choices can be linked to the following:

/one\|two\|three

Match "One", "two" or "three".

To match multiple repetitions, the entire choice structure should be placed between "\ (" and "\)":

/\ (foo\|bar\) \+

This command matches "foo", "Foobar", "Foofoo", "Barfoobar", and so on.

Another example:

/end\ (if\|while\|for\)

This command matches "endif", "Endwhile" and "ENDfor".

Viemu plug-in vim for Visual studio installation cracked

Build _VIEMURC as Viemu profile under current user directory "C:\Users\Administrator"

Download Vimenu

. Cracked

1. Delete directory C:\Documents and Settings\ username \local Settings\Application Data\identities\{ 17582A9E-740A-47F2-8256-D09F1378E7FA}

2. Delete registry key HKEY_CURRENT_USER\SOFTWARE\CLASSES\CLSID\{D31F31E1-B08F-46FF-92C5-CA111A2053DF}

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.