Vim USR DOC --- No.2 ---

xiaoxiao2021-03-06  68

Vim Version 6.3. Finally Modified: June 2004

VIM User Manual - Bram Moolenaar

(Translator: nek_in http://vimcdoc.sf.net)

Vim first step

This chapter provides sufficient information to make you use Vim to do basic editing. The method provided here is not necessarily efficient

Fast. But at least it is effective. It takes some time to practice these commands, which is the foundation of the following knowledge.

|

02.1 | First run VIM

|

02.2 | Insert text

|

02.3 | Mobile cursor

|

02.4 | Delete characters

|

02.5 | Undo and heavy

|

02.6 | Other editing commands

|

02.7 | Exit

|

02.8 | Seeking help

Next chapter: | |

USR_03.txt | Mobile

Previous chapter: |

USR_01.txt | About this manual

Directory: |

USR_TOC.TXT |

* 02.1 * First run VIM

The command to start the VIM is as follows:

gvim file.txt

In UNIX operating systems, you can enter this command at any command prompt. If you use Microsoft

Windows, start an MS-DOS window, and enter this command.

No matter which way, now VIM starts to edit a file called File.txt. Because this is a new

File, you will get an empty window. The screen looks like this:

---------------------------------------

| # |

| ~ |

| ~ |

| ~ |

| ~ |

| "file.txt" [new file] |

---------------------------------------

('# "Is the location of the current cursor)

The line starting with the corrugated line (~) indicates that the row does not exist in the file. In other words, if the file opened by VIM cannot be filled

This displayed screen, it will display the row at the beginning of the corrugated line. On the bottom of the screen, there is a message line indicator file

Named File.txt and shows this is a new file. This information is temporary, new information can overwrite it.

Vim command

The GVIM command creates a new window for editing. If you use this command:

Vim file.txt

Then edit in the command window. In other words, if you are running in xterm, the editor uses the XTERM window.

If you use the MS-DOS window of Microsoft Window, the editor uses this MS-DOS window. Two

The text displayed by the version looks the same. But if you use GVIM, there will be other features, such as a menu bar.

There will be more descriptions later.

* 02.2 * Insert text

Vim is a multi-mode editor. That is, in different modes, the editor response is different. In normal mode

Next, the characters you knocked into it are just commands; and in the insert mode, the characters you are knocked into the inserted text.

When you just entered Vim, it is in normal mode. You can start by knocking into the "i" command (i is an abbreviation for INSERT)

Insert mode, so you can enter text, which will be inserted into the file. You don't have to worry about errors, you can then fix it. To enter the programmer of the following oil poetry, you can knock this:

IA Very Intelligent Turtle

Found Programming Unix a hurdle

After entering "Turtle", you start a new line by entering the carriage return. Finally, you entered the key to exit the insert mode.

Back to normal mode. Now there are two lines of words in your VIM window:

---------------------------------------

| A Very Intelligent Turtle |

| Found Programming Unix a hurdle |

| ~ |

| ~ |

| | |

---------------------------------------

What is the mode?

To see what model you are, enter the following command:

: Set ShowMode

You will find that when you knock in the colon, VIM will shift the light to the last line of the window. There is a "colon command" there.

(With the order of order begins), the input of this command is knocked into the return of this command (all colon commands are used.

This way is ended).

Now, if you enter the "i" command, Vim will display - ISERT at the bottom of the window - (Chinese mode

Displayed - Insert - - Translator Note), which means you insert mode.

---------------------------------------

| A Very Intelligent Turtle |

| Found Programming Unix a hurdle |

| ~ |

| ~ |

| - INSERT - |

---------------------------------------

If you enter back to normal mode, the last row becomes blank.

Solve the problem

A new question that VIM often encounters is that I don't know what model it is in what model, it may be because I forgot, it is possible

Because I accidentally knocked a command of switching mode. No matter what model you are, go back to normal mode, only

It is ok to knock . Sometimes you need to knock twice, if VIM issues a "嘀", you have already

In normal mode.

* 02.3 * Mobile cursor

After returning to normal mode, you can use the following command to move the cursor:

H left * hjkl *

j under

K

l right

These commands look casually. In any case, who heard that L is correct? But in fact, do these choices

It is reason to: Moving the cursor is the most common editor command. And these bonds are the right hand in your place. That is to say:

This key setting allows you to perform mobile operations at the fastest speed (especially when you use ten fingers).

Note:

You can also use the arrow keys to move the cursor, but this will slow down your speed, because you have to put your hands from

The alphabet key moves to the arrow key. Imagine, you have to do this for a few hundred times in an hour, this can spend

Quite more time.

Moreover, there are some keyboards that have no arrow keys, or placed in some very special places. and so,

I know that HJKL's usage is very helpful in these cases.

One way to remember these commands is: h on the left, l on the right, J pointed to the bottom. Representation is as follows:

k

H L

j

The best way to learn these orders is to use it. Enter more text with the "i" command. Then move with the HJKL key

Cursors and some words are entered in some places. Don't forget to switch back to normal mode with . | vimtutor | is also a

Good way to practice.

* 02.4 * Delete characters

To delete a character, move the cursor to it and enter "X". (This is a return to the previous typewriter,

At that time, you removed it on characters), for example, shifting the light to the lead, then enter xxxxxxx (seven x)

You can delete "a very". The result looks like this:

---------------------------------------

Intelligent Turtle |

| Found Programming Unix a hurdle |

| ~ |

| ~ |

| | |

---------------------------------------

Now you can enter new characters, for example, by entering:

Ia Young

This command starts an insertion operation (That "i") and inserts "a young" and then exits

Insert mode (last ). turn out:

---------------------------------------

| A Young Intelligent Turtle |

| Found Programming Unix a hurdle |

| ~ |

| ~ |

| | |

---------------------------------------

Delete one line

To delete a single line, use the "DD" command, then move it to fill out the empty line left:

---------------------------------------

| Found Programming Unix a hurdle |

| ~ |

| ~ |

| ~ |

| | |

--------------------------------------- Delete a branch

In Vim, you can connect two lines, which means that the newlines between the two lines are deleted. "J" command

Used to complete this function.

The following two acts:

A young intelligent

Turtle

Move the cursor to the first line, then press "J":

A Young Intelligent Turtle

* 02.5 * Undo and heavy

Suppose you have deleted too much now. Of course, you can re-enter the required content. However, you still have a simpler

select. The "U" command revokes the previous editing operation. Take a look at this: first use "DD" to delete a line, knock

"u", the line is back.

Give another example: move the cursor to the first row of A:

A Young Intelligent Turtle

Now enter XXXXXXX to delete "a young". The results are as follows:

Intelligent Turtle

Enter "U" to revoke the last delete operation. That delete operation deletes the character g, so the undo command recovers this character:

G Intelligent Turtle

The next u command recovers the penultimate deleted character:

NG Intelligent Turtle

The next U command recovers U, so push:

Ung Intelligent Turtle

OUNG Intelligent Turtle

Young Intelligent Turtle

Young Intelligent Turtle

A Young Intelligent Turtle

Note:

If you enter "U" twice, your text restore the original, it should be your Vim is configured in VI compatibility

Mode. See this question: | Not-compatible |.

This article assumes that you work in "Vim". You may prefer the model of old VI, but you must

Be careful herein some small differences.

Redo

If you cancel too much, you can enter Ctrl-R (Redo) to return the previous command. In other words, it revoked

An undo. To see the example, enter Ctrl-R twice. Character A and the space behind it appear:

Young Intelligent Turtle

There is a special version of the revocation command: "U" (row revoking). Row revocation command revokes all in the previous editing line

The operation. Enter these commands twice to cancel the previous "U":

A Very Intelligent Turtle

XXXX Delete Very

A Intelligent Turtle

XXXXXX Delete Turtle

A Intelligent

Use "u" to recover line

A Very Intelligent Turtle

Use "u" to revoke "U"

A Intelligent

The "U" command itself is a changing operation, the "U" command revokes the operation, and the ctrl-r command will do this.

A little chaotic, but don't worry, use "u" and ctrl-r command you can switch to any of your editing.

* 02.6 * Other editing commands

Vim has a lot of commands to modify the text. See | Q_IN | and below. Here is some often used:

Add to

The "i" command is inserted into the character in front of the character where the cursor is located. Under normal circumstances, this is enough, but if you just want to add things in the tail? To solve this problem, you need to insert characters after text. This adopts "A" (Append)

Command implementation.

For example, to put as follows

And That's Not Saying Much for the Turtle.

Change to

AND That's not saying much for the title !!!

Make the light to the end of the row. Then enter "X" to delete it. Now the cursor is in a row, now input

a !!!

Add three exclamation points to Turtle's "e":

AND That's not saying much for the title !!!

Open a new line

The "O" command establishes a new blank line below the cursor and switches the VIM to the insert mode. Then you can be here

Enter the text in the new line.

Assume your cursor somewhere in the first line of the following two lines:

A Very Intelligent Turtle

Found Programming Unix a hurdle

If you use the "O" command and enter your new text:

Othat Liked Using Vim

The result will be:

A Very Intelligent Turtle

That LiKed Using Vim

Found Programming Unix a hurdle

The "O" command (uppercase) opens a new line on the cursor.

Specification

Assume that you want to move 9 lines, you can enter "KKKKKKKKKKK" or you can enter "9k". In fact,

You can add a number in front of a lot of commands. For example, in front of this chapter, you pass "A !!! "

Add three exclamation points. Another method is to use the command "3A! ". Time 3 requires the back of the command

Execute three times. Similarly, to delete three characters, you can use "3X". The number of times is always putting it multiple times.

The front of the command.

* 02.7 * Exit

Use the "zz" command to exit. This command saves files and exits.

Note:

Unlike other editors, Vim does not automatically create a backup file. If you enter "ZZ",

Your modification takes effect immediately and cannot be recovered. You can configure VIM to make it a backup file,

See | 07.4 |.

Discard

Sometimes you have made a series of modifications suddenly found that it is not as good as editing. Don't worry, vim has "giving up modification

And exit "command, that is:

: q!

Don't forget to press Enter to make your order take effect.

The details of this command are: commands with three parts, including colons (:), which makes VIM into command mode,

q Command, it tells Vim to exit, and exclamation mark is forced command modifier.

Here, it is necessary to force command modifiers, which is forced to ask VIM to give up modification and exit. If you are just

Enter ": q", Vim will display an error message and refuse to quit:

E37: No Write Since Last Change (use! To override)

By specifying forced execution, you actually tell Vim: "I know that I do it is stupid, but I grow up,

Know what you are doing. "

If you want to re-edit after you give up your modification, you can reload the original file with the ": e!" Command. * 02.8 * Search for help

All what you want to know, you can find the answer in the Vim Help file, just ask!

To get a general help with this command:

: Help

You can also use the first function key . If there is a key on your keyboard, it may be effective.

If you don't specify a topic, ": Help" displays a summary help window. Vim's author is helping

In terms of the use of a very smart program (maybe it is a very lazy solution): they use a normal editor window

Port shows help. You can use any normal vim command to move the cursor in the Help window. So H, J, K

And L is still left, lower, up, and right.

To quit the help window, use the command to exit a normal window: "ZZ". This will only quit the help window without

Exit Vim.

When you read your help, you will find that some texts have been enclosed in a pair of vertical lines (for example, | Help |). this means

A hyperlink. If you move the cursor between the two vertical lines and press Ctrl -] (Label Jump Command), help

The system will lead you to the topic pointing to this hyperlink. (Because it is not the focus of this chapter, it will not be discussed in detail here.

VIM's term "tag" (tag) is "tag", so ctrl-] is actually a name where jumps to the cursor.

The location of the label is located. )

After jump a few times, you may want to go back to the original place. Ctrl-t (label and stack) sends you back to the previous one

Jump point. Ctrl-o (jump to the previous position) can also complete the same function.

On the top of the help screen, there is a symbol: * help.txt *. This name is used to help the system to define a label

(That is, a superlink target).

See | 29.1 | You can learn more about the label.

To get a specific topic, use the following command:

: Help {Topic}

For example, to get the help of the "X" command, enter the following command:

: Help X

To know how to delete text, use the following command:

: Help Deleting

To get the help index of all commands, use the following command:

Help Index

If you need to get a help of commands that contain control characters (such as Ctrl-a), you can be in front of it

Plus the prefix "Ctrl-".

Help Ctrl-a

Vim has many modes. By default, the help system displays commands of normal mode. For example, the following command is displayed

Help for the Ctrl-h command:

: Help Ctrl-H

To represent other modes, you can use the mode prefix. If you need to insert a mode help, use "i_"

. For example, for Ctrl-h, you can use the following command:

: Help i_ctrl-h

When you start VIM, you can use some command line parameters. These parameters begin with short horizontal lines (-). For example, know -t

This parameter is dry, you can use this command:

: Help -T

Vim has a lot of options to let you customize this editor. If you have to get the help of the option, you need to enclose it in one.

Single quotes. For example, if you know what 'Number' is done, use the following command:

: Help 'Number'

If you see an error message you can't understand, for example:

E37: No Write Since last change (use! To override) You can use the Error number of using E to find help:

: Help E37

转载请注明原文地址:https://www.9cbs.com/read-111960.html

New Post(0)