VI usage description

Source: Internet
Author: User
From: http://www.linux521.com/vi.htm

----VI Introduction

---- VI is an editor in Linux. Its usage and interface are very similar to those on UNIX platforms. In Linux, there are many powerful and user-friendly editors, but VI is worth learning how to use it. When you get started with Vi, you think its interface is unfriendly and difficult to master. However, once you have mastered the VI command, you can feel its powerful functions and efficiency. Besides, VI is relatively small. You can always use vi no matter you use any Linux system. In many systems, you may only choose VI. --

----Inbound and Outbound

---- To import the VI file, you can directly connect the VI file to the system prompt and press the VI file name, vi can help you upload the files to be edited or start a new file. After entering VI, the left side of the screen will display the current wave character number. If this character number is at the beginning of the column, it will be blank before the table. To remove Vi, you can press "Q" and "WQ" to save the file and then open it (Note that the number is not valid ). The [ESC] key is used to switch to the specified model. If you do not know what the model is, you can press [ESC] several times to send a beep to the system to make sure the input refers to the model.

----VI input mode

---- How can I input materials? There are several commands that can be input to the input mode:

Add (append)
---- A starts to add new resources from the position behind the bid, and the resources after the bid are moved to the backend with the newly added resources.
---- A starts from the ground at the bottom of the optical mark.

Insert)
---- I start from the position of the optical standard, and start to insert the materials into the background. The materials after the optical standard move forward with the newly added materials.
---- I starts from the front of the first non-empty white character in the optical label column.

Open)
---- O adds a new column under the column of the optical mark and enters the input mode.
---- O adds a new column on the column of the optical mark and enters the input mode.

-----Delete and modify

---- What is the compilation? In this case, we consider it a new addition, modification, and deletion of text, including moving and re-partitioning of text block. This section describes how to delete and modify VI. (Note: In the original concepts of VI, it is two sub-tasks to input and compile the series. Editing is performed in a model-based model. It is used to determine the location where the series is to be edited, then, it means to make the compilation .)
---- X deletes the font of the optical mark.
---- Dd deletes the column where the cursor is located.
---- R is used to modify the font of the optical mark, and R is followed by the font to be corrected.
---- R enters the form of substitution. The newly added resource will overwrite the original resource and go directly to the [ESC] mode and go back to the model.
---- S Delete the font in which the optical mark is located, and enter the input mode.
---- S: Delete the column in which the cursor is located, and enter the input mode.

----
Here we will list the commonly used operation commands in VI.

  1. Input mode command
  2. Input mode command cursor Movement
  3. Input mode command delete operation
  4. Change and replace
  5. Query command
  6. Copy and paste
  7. Save and exit vi

Input mode command

Input/Output Method

Command Function
<A> Enter Text behind the cursor
<A> Enter text at the end of the current row
<I> Input text before the cursor
<I> Enter text in the current line
<O> Enter a new row after the current row
<O> Enter a new row before the current row

Cursor movement command

Move cursor

Command Function
<B> Move to the start of the current word
<E> Move to the end of the current word
<W> Move a word forward
<H> Move one character forward
<J> Move up a row
<K> Move a row down
<L> Move one character backward

Delete Operation Command

Delete operation

Command Function
<X> Delete the character of the cursor
<DW> Delete the word with the cursor
<D $> Delete all characters from cursor to end of line
<D> Same as <D $>
<DD> Delete current row

You can add a number before the DELETE command, for example, <5x> to delete five lines.

Change and replace operation commands

Change and replace operations

Command Function
<R> Replace the character of the cursor
<R> Replacement Character Sequence
<CW> Replace a word
<Ce> Same as <CW>
<CB> Replace the previous character of the cursor
<C $> Replace all characters from the cursor position to the end of the line
<C> Same as <C $>
<CC> Replace the current row

Query command

Query

Command Function
</ABC> Forward query ABC
<? ABC> Backward query ABC
<N> Forward Query
<N> Continue backward Query

Copy and paste commands

Copy and paste

Command Function
</YW> Upload the word with the cursor to the clipboard.
<Y $> Hover the cursor to the end of the line into the clipboard
<Y> Same as <Y $>
<YY> Upload the current row to the clipboard.
<P> Paste the content in the clipboard after the cursor
<P> Paste the content in the clipboard before the cursor

File Save and exit VI command

Save and exit vi

Command Function
<: Q> Exit Without saving the package
<: Q!> Do not save mandatory exit
<: W> Save and edit
<: W filename> Store in Filename
<: W! FILENAME> Forcibly saved to file filename
<: WQ> Save and exit
<: X> Same as <: WQ>
<ZZ> Same as <: WQ>

 

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.