Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Unix basic tutorial 8 Editor vi

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Type

1) Line Editor: edit units for rows. Edit 、 e 、 ex

2) screen editor: edit units in characters. Vi 、 v 、 view

2 、 vi

1) Command mode

(1) cursor movement

(2) Delete, paste, and find text

(3) Command key

1. Cursor movement

Move the ←↓↑→ cursor left, down, up, and right

Move the h j k l cursor left, down, up, and right

^ move the cursor to the beginning of the line

Move the cursor to the end of the line

+ move the cursor down one line

_ move the cursor up one line

Move the spacebar cursor to the left

Move the return key cursor to the right

two。 Delete text

X Delete the character where the cursor is located

Dw deletes the cursor to the suffix

D delete the cursor position to the end of the line

Dd deletes the line of the cursor

Preceded by a number indicates that multiple units are deleted at the same time

3. Replace text

R character replacement command

Cw word substitution command

4. Search for text

/ the character you are looking for starts looking backwards with the current cursor.

-n continue searching backward

-N keep looking forward

? The current cursor starts to look forward

5. Auxiliary command

U cancel the previous command

. Repeat the previous command

J connects the next line to the end of the current line

After pasting the content deleted by the previous delete command to the current cursor, the following content moves backward.

6. Combined use

2dd/p delete paste (the previous number 2 can be changed)

2yy/p copy and paste

7. Save text

Wq saves and exits

W save, do not exit

W file is saved to the file file and does not exit

Q exit

: q! Forcibly exit, do not save

Exit ": wq"

2) text input mode

(1) enter text

(2) Command key

I insert text before the cursor

I cursor line beginning

An add text after the cursor

A cursor end of line

O add a new line under the line where the cursor is located

O add a new line above the line where the cursor is located

Esc exit

3) basic use

(1) vi file

(2) vi-r file was last modified but saved, recovery interrupted unexpectedly, continue to work

(3) after vi file1 file2 w is saved, n edits the next file

(4) vi-x file password

4) execute unix command in vi

(1) exclamation point! ! ls

(2) r! Remols put the contents listed by ls in vi (at the cursor)

(3) 2R! Embed the contents of the command in the second line

(4) Command line editing function ($set-o vi)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report