Use vim (2): common functions and use functions of vim

Source: Internet
Author: User

Use vim (2): common functions and use functions of vim
1. Common vim Functions
Common functions of vim, including block selection, copying, multi-file editing, and multi-window functions.
2. vim Block Selection
Block Selection is to copy and paste one part of the document without the entire line of processing. Press v, V, Ctrl + v to select the block. Appears in the lower left corner

-- VISUAL LINE --
V: select the character, and select "V" for the reversed area of the cursor. Select "Ctrl + v" for the entire line after the cursor. Select "y" for the rectangle: copy the Selected Location d: Delete the selected location
Copy the data copied by y, find the appropriate position, and paste it by p.
3. Multi-file editing
Multi-file editing allows vim to open multiple files at a time. These files can be easily copied and pasted. Otherwise, if two vim files are used, they can only be copied and pasted with the mouse. Open multiple files:
vim test1 test2
: N: Edit next file: N: Edit last file: files: list all files opened by vim
$ Vim test test1: files 1% a = "test" line 1 2 # "test1" line 24yy # copy 4 rows: n # Open another file p # paste: q! # Exit

4. Multiple windows
Vim's multi-window display allows you to conveniently display multiple files. You can copy and paste the data in two windows in yy mode. : Sp [filename]: open a new window. filename can be blank. If it is empty, open the current file Ctrl + w + j: Move the window below. Press Ctrl + w to open it first, then j or press Ctrl + w + k: Move the top window Ctrl + w + q: exit the file, the same as q
Address: http://blog.csdn.net/yonggang7/article/details/38455105


A commonly used VIM shortcut key table, such as opening a new window, within 2 pages

H. Move a character to the left.
J move a character downward with the cursor
K move the cursor one character up
L move the cursor one character to the right
W: Move a word to the back ~ You need to use this word before you can understand it.
If you want to move multiple times, for example, move 30 rows down, you can use 30j to pull ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Edit mode:
I don't need to mention this. I can directly enter the insert mode ~
O I like this command! It is to insert a new row under the row and automatically enter the insertion mode. If the O (large O) is used, it is from the top of the current row ~
The a command is used to enter the insert mode, but unlike I, it will return a backward character, which is very useful! You will know how to pull it when writing C language!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
Some Common commands:
Ctrl + f move a page down, that is, the page down
Ctrl + B move one page up, which is the role of page up

Some Common commands. I think it is useful! Let's take a look at it. It's common! In upper case, shift + cha will be pulled.
H move the cursor to the row at the top of the screen
G move the cursor to the lowest line of the entire document
L which line should the cursor move to the bottom of the screen?
J (uppercase) The command function is to combine the line and the next line into a line
$ Move to the end of the line
* This asterisk has the search function ~ It will search for the word on your cursor and automatically move the cursor to the next word ~
0 (zero) Move to the beginning of the line
U is quite useful! Is to restore the meaning of the previous action. Return to the previous action, which is equivalent to the ctrl + z command in the graphic editor.
Ctrl + r is the opposite of u. This is to redo the previous action.
. You are not mistaken! This is a period in English! Powerful functions. Repeat the previous action! Remember, it's repeated ~ Not restoration ~
/Word: search for a string named word under the cursor. Eg: Search for yutao and then pull/yutao.
? Word searches for a string named word over the cursor.
N indicates repeating the previous search. For example, if you search for/yutao, you can search for yutao again.
N is the opposite of the small n function, which repeats the previous one. This is reverse search ~ Hey
: N1, n2s/word1/word2/g is replaced. It means that from the line n1 to the line n2, We can find word1 and replace it with word2. If we replace n2 with $, it means from that row to the last row, if we change g to gc, you can try it ~ It will prompt you whether to delete it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copy. Paste. Delete.
X. You will know it when you use it ~ Is to delete the current character
D. This is what delete means ~ Next I will introduce her usage!
Dd deletes a whole row! If it is 30dd, 30 rows will be deleted ~
D1G deletes the data from the cursor to the first row.
DG deletes the data from the cursor to the last row...
D $ indicates what it means ~ It's the end of the line!
Yy: This is the row where the copy cursor is located! Very useful!
Nyy, n is the meaning of a row. Let's guess its function.
Y... the remaining full text>

Common commands of the vim Editor, all?

This is a vim tutorial. You can modify it directly. Due to word limit, send it to an email address.
Vim is a powerful editor with many commands. Limited space, in this tutorial
I will not go into details. The purpose of this tutorial is to describe some necessary basic commands.
Some commands, you can easily use vim as a universal editor.

It takes about 25-30 minutes to complete this tutorial, depending on your training time.

The command operations in each section will change this article. We recommend that you copy a copy of this article and
Training (if you start the tutorial through vimtutor, this article is already a copy ).

Remember: the design concept of this tutorial is learned during use. In other words, you need
Execute commands to learn their correct usage. If you only read and do not operate, you may
These commands will soon be forgotten!

Now, please make sure that your Shift-Lock (case-insensitive key) has not been pressed, and then press the key on the disk
The cursor key j is enough times to move the cursor until the content in section 1 is fully filled with the screen.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lecture 1 Section 1: move the cursor

※To move the cursor, press the h, j, k, and l keys respectively. ※※

^
K indicates that the key of h is on the left, and is moved to the left every time you press it.
H l's key is on the right, and will move to the right each time you press it.
The j key looks like a downward arrow at the tip.
V

1. move the cursor freely on the screen until you feel comfortable.

2. Press the downstream key (j) until the cursor repeats.

--- Now you should have learned how to move to the next lecture.

3. now use the downstream key to move the cursor to lecture 2.

Tip: If you are not sure about the letter you press, Press ESC to return to Normal mode.
Enter the command you want on the keyboard again.

Tip: The cursor key should work properly. However, with the hjkl key, you can quickly
Move the cursor around the screen.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lecture 1 Section 2: VIM entry and exit

!! Note: Please read the entire section before you can execute the commands described below.

1. Press ESC (this is to ensure that you are in normal mode ).

2. Enter q! Enter

--- Exiting the editor in this way will never save the changes you have made since entering the editor.
If you want to save the changes and exit, enter:
Wq press ENTER

3. If you see a command line prompt, enter the command that can bring you back to this tutorial, that is:

Vimtutor press ENTER

In general, you can also use this method:

Vim tutor press ENTER

--- 'Vim 'indicates entering the vim Editor, while 'tutor' indicates the file you want to edit.

4. If you are confident that you have kept these steps in mind, please exit from step 1 to step 3.
Then enter the editor again. Next, move the cursor to section 3 of the first lecture to continue our tutorial.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lecture 1 ...... remaining full text>

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.