Vim use

xiaoxiao2021-03-06  43

Introduction to VIM

Vim is an extremely popular full-screen book editor in UNIX world, almost any unix machine will provide this software. After familiar with the document processing under DOS, you may feel that Vim is not easy to use; there are many updated, more useful instrument editors, but not necessarily installed on each UNIX machine. . So, learning VIM's basic operation is still good, so you have your heart in different machines.

Vim Basic Concept

Unix provides a range of EX editors, including EX, EDIT, and VIM. Compared with the full screen editor, it is now possible to imagine how to use EX, Edit, which has been used by DOS 3.3, which is used by EDLIN?). VIM's original interest is "vi improved", it is an editorial program you have seen, that is, you can immediately see the results.

Also because Vim is a full screen editor, it must control what the entire terminal screen will show. There are many kinds of terms, and the characteristics are not the same, so the VIM is necessary to know which terminal is now used. This is set by the TERM environment variable to set the environment variable aspects, please see the description of the shell used. (Responds to Unknow Terminal Type when performing VIM, otherwise you can set it.)

As long as you perform VIM, you can enter the editing environment of VIM. It will be better to have a rough understanding of it before actual operation. Vim has two modes, input mode, and instruction mode. The input mode is used to enter text data, and the instruction mode is an operational instruction used to meet some of the arrangement files, archives, and leaving VIM, etc. When Vim is executed, you will enter the instruction mode, and any of the characters entered at this time is considered to be instructions.

Enter and leave

To enter VIM, you can type the VIM

VIM input mode

How do you enter your information? There are several instructions to enter the input mode:

Added (Append)

A From the position where the cursor is located, the new data is started, and the data after the cursor moves backwards with the new data.

A starts adding information from the last place where the cursor is located.

Insert (Insert)

i From the front of the cursor where the data is inserted, the data after the cursor moves backwards with the new data.

I starts inserting information from the first non-empty white font in the column where the cursor is located.

Start (Open)

o Add a column and enter the input mode under the column where the cursor is located.

O Add a column above the column where the cursor is located and enters the input mode.

Perhaps the text narrative looks a bit complicated, but as long as you actually do it, you can understand these ways. Practices are important, especially computers, you can try and verify results at any time. It is best to use it to use it without a fierce, and there is a halving utility. (Note: This paragraph is nonsense.)

Vim Basic Edit

With the function keys on the typical keyboard, like the arrow keys, [INSERT], [Delete], etc. Now you should already use Vim to handle text information. Of course, VIM also provides other many features that make the text more convenient, interested, please continue.

Let's go to the BCC before you continue. There are many labels, different hardware and operation systems. The PC is not only IBM PC and its compatibility. In fact, including keyboard, terminal, etc. often have different specifications. What does this represent? In the editing software of the instrument, there will be such problems, and there are no specific functions on the keyboard of some computers! So don't you have some features? This problem is the same in the UNIX system, almost major computer vendors have their own UNIX systems, while Vim's operating methods will also be inserted. We can use the PC's keyboard to explain the operation of Vim, but still have to mention this problem.

Delete and modification

What is edited? Here we think that the new modification of the text and delete, even include the movement, replication, etc. of the text block. Here first describes how to delete and modify VIM. (Note: In the primitive concept of Vim, the input and editing is two yards. Editing is in the command mode, first using the command to move the cursor to locate the place where you want to edit, and then you will edit.)

x Delete the cursor where the cursor is located.

DD Deletes the column where the cursor is located.

r modifies the cursor where the cursor is located, and the character to be corrected will be corrected.

R Enter the substitution state, the new information will overwrite the original information until [ESC] is pressed back to the instruction mode.

s Delete the cursor where the cursor is located and enter the input mode.

S Delete the column where the cursor is located and enter the input mode.

In fact, there is not so troublesome on the PC! Entering and editing can be done in the input mode. For example, you want to delete the character, press [Delete] directly. The insertion state and the replacement state can be used directly with [INSERT], and the editing instructions of any instruction mode are not used. However, as mentioned earlier, these instructions can be used per terminal, not just on the PC.

The basic instructions of moving the cursor in the instruction mode are H, J, K, L. I want to come to you now you should also guess the direction of the PC directly using the PC, and whether it can be in the instruction mode or input mode. Many easier.

Of course, the PC keyboard is also inadequate. There is a very good instruction u to restore the deleted information, and the U command can restore all changes in the cursor where the cursor is located. This is the same as the [UNDO] button on some computers.

Vim advanced application

I believe that I should have considerable understanding for VIM. Don't have any trouble for processing text. If you are interested in making good functions with other features of Vim, continue to look down.

Move cursor

Since many editing work is positioned by cursors, VIM provides many way of moving cursors, which we are listed in a few profiles (these of course are instructions in command mode):

Directive Description Function Key 0 Move to the Most HOME $ Move Home $ Move to the Cursor Allows to the Last End ^ D ^ D Down Page ^ f Previous Page Page ^ B Page Pageup

Instruction Description h Move to the first column M moved to the window M move to the window of the window to move to the last column B moving to the window M move to the first letter W moving to the next word, the first letter E moved to the lower The last letter of the word ^ moves to the first non-empty-white character in the column where the cursor is located

Instruction Description N-minus Move to the first non-empty-white character N plus number moved to the next column, the first non-empty white character NG Directly uses the digital N plus uppercase G moves to the Number N columns

The instruction description fx moves to the right to the X-element FX to move to the left to the X-cell TX to move to the X-character TX to move to the X-character; with F & T, repeat, with F & T, Repeat one / string to move to the right to move to the right place? String moves to the left to the String place n-match / &? Use, repeat N-match / &? Use, repeat in the opposite direction

Instructions Note N (the left parentheses move to the forefront of the sentence, the front plus the number can specify the forward N sentences to move n)!. The front plus the number can be specified to move N sentence n {the left left parenthest direction to the front of the paragraph, the front plus the number can specify the forward N paragraph paragraphs in front of the paragraph, the blank column between paragraphs defines n} Right arc moving In the forefront of the next paragraph, the front plus numbers can specify that the N paragraphs will not try to recite these instructions, otherwise the consequences are responsible. They look more and messy, in fact, this is the obstacle to the text narrative itself. Again again, actually use it as long as a few times, you can directly download these wonderful strange instructions, far more than the death of the death. (Note: If you really don't want to delete information with me. In addition, this paragraph is nonsense.)

Advanced editing instruction

These editing instructions are very flexible, basically, constructed from instructions and scope. For example, DW is composed of deletion instruction D and a range W, representing a word D (EletE) W (ORD).

The list of instructions are as follows:

D Delete (Delete)

Y replication (YANK)

P Placement (PUT)

C Modification (Change)

The range can be the following:

E Cursor location to the last letter to the word

W cursor location in the first letter to the next word

B cursor location first letter to the previous word

$ Cursor location to the last letter of this column

0 Cursor location to the first letter of the column

) The first letter where the cursor is positioned to the next sentence

(The first letter in the position of the cursor to the sentence

} The last letter where the cursor is located to the paragraph

{Cursor location to the first letter of this paragraph

To be honest, combined these instructions to edit the file with a little art atmosphere. Anyway, they provide more capabilities of editing text. It is worth noting that the deletion and replication will put the contents of the specified range in the temporary area, and then you can use the instruction P to go to it elsewhere, which is the way VIM used to process segment copy and movement.

Some VIM versions, such as the ELVIMS used by Linux can greatly simplify this 坨 instruction. If you look at these editing instructions, you will find that the problem is actually a scope, in fact, there are only four instructions. The command V is very easy to use, as long as the V key is pressed, the position where the cursor is located will be inverse, and then the cursor can be moved to set the range, then the instructions are then directly edited.

For the entire operation, VIM additionally provides more convenient editing instructions. The command DD that has been removed over the entire column is one of them; the CC can modify the entire text; and YY is copying the entire text; the command D can delete the cursor to the column to end all the text.

Archive instruction

The file instructions are mostly: start, and the editing directive is a bit different. For example, the instructions mentioned earlier are: Q. It is now briefly description as the end of this story:

: Q End Editing (QUIT)

Use: Q! Forced to leave if you don't want to archive.

: w Archive (Write)

Thereafter, you can add the file name to be archived.

The file instruction can be combined, for example: WQ is that the arch will leave.

ZZ function is: WQ is the same.

Also worth mentioning is a partial archive function of VIM. You can use: N, MW FileName to go to the specified FileName in the specified FileName of the word N-R line to the MW FileName. The times are changing, the world is changing, and VIM is also changing, but it is roughly like this. Ok, I am willing to live a happy life with the princess since then.

: WQ

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

New Post(0)