VI usage in Linux/Unix.

Source: Internet
Author: User

VI (M) has a built-in VI (m) Editor in most Unix systems (including Linux. It is also a common text editing tool.

However, people who are used to the window text editing tool are used to moving the cursor with the mouse or the "up/down" key,

However, in some Linux/UNIX operating systems, VI does not support moving the cursor by the "up/down" key, which makes it a headache for some new users.

 

However, as long as you spend a little time figuring out its habits, you can use it easily !!

 

First, there are three modes of VI:

 

Normal Mode

In normal mode, you can only move the position on the cursor screen, Mark, delete, move, copy character or text block. In addition, you can enter the command column mode in command mode.

Input mode

You can enter text materials only in input mode. Press ESC to return to normal mode.

Command column Mode

You can also set the editing environment, such as searching for strings and listing row numbers, by writing files to or leaving the editor.

 

How to switch between modes:

◆ General mode ---- → editing mode: In general mode, press 'I', 'A', or 'O' to enter the editing mode.

 

"I" insert-Insert the text to be entered at the current cursor

"A" APPEND-Enter text in the next line where the current cursor is located

"O" open-Add a row under the cursor and input text from the beginning of the row

◆ Editing mode ---- → general mode: Press ESC

◆ General mode ---- → command mode: In general mode, you can press ':' or '/' or '? 'Key to enter the command column Mode

: W filename (stored in the specified file)

: WQ (write and exit VI)

: Q! (Force exit and discard the edited file)

: N [file]-introduce the next file

: L, l2d-delete text from self-built l to row L2

: Set nu (list row numbers)

 

: Nu (to line Nu)

/Word (search from the beginning to the end), press n to continue searching

Basic operations of VI:

 

◆ Move the cursor in Normal Mode

H, J, K, and l: control the cursor to the left, bottom, Earth, and right

 

◆ Some common operations in Normal Mode

 

CTRL + B: Previous Page

CTRL + F: Next page

G: Move to the end of the file

W: Move to the beginning of the next word

B: Jump to the beginning of a wore

X: Delete the next character.

DD: Delete the row where the cursor is located

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.