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

How to use vi command in linux system

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

Share

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

This article introduces you how to use the vi command in the linux system, the content is very detailed, interested friends can refer to, hope to be helpful to you.

1.: set nu displays the line number

2. Gg- to the beginning of the file

3.G-to the end of the file

4.u-undo operation

5. Ctrlaccounr-redo

Enter 6.:/better, find the word that matches better, and press n to find the next one.

Enter 7.:s/better/dog and replace the first better of the line with dog.

Enter s/better/dog and replace all the better of the bank with dog

Enter% s/better/dog and replace all better in this file with dog

8. Vi-O2 file1 file2

Use one screen to display two file1,file2 files at the same time, easy to edit, press ctrl+w to switch from one file to another file window.

Expand content

Linux common commands

-learned

Cd (path switching) rm (followed by-rf deletes files or folders) ls (view files and folders under the current path) mkdir (create folder) touch (create files)

Cat (view file contents) mv (move files, or rename files) rmdir (delete empty folder) whoami (view current user) pwd (view current path)

-/ # Root directory the linux system has no drive letter, only the root directory /.

-cd # directory jump

-cp # copy file cp /

# copy folder cp-rf

-find # find the file find / (path)-name'* .py'

Find / (path)-size 1024 (+ 1024 greater than 1024;-1024 less than 1024)

Sudo find. # sudo gets permission

Commands commonly used in Vim

Cursor positioning

Hjkl moves up and down, left and right.

0$ skip to the beginning or end of a line

Gg shift+G jumps to the beginning or end line of the entire file

1G, 2G, 3G.NG, skip to the beginning of line 1.2.3 N

/ String (n N can be cycled) quickly navigate to a line

/ ^ d quickly navigate to the line that starts with d

/ txt$ quickly locates to the line ending with txt.

Text editing (a small amount)

Y copy. Yy 3yy ygg yG (in behavior units)

D Delete dd 3dd dgg dG (in behavior units)

P paste

X Delete the character where the cursor is located

D delete from the cursor to the end of the line

U undo undo

^ r redo undo, redo Ctrl + r

R modify a character

Enter other modes

An enter insert mode and insert behind the cursor

I enter insert mode and insert in front of the cursor

O insert another line

A shift + An inserts at the end of the current line

: enter the last line mode (extended command mode)

V enter visual mode

^ v enters visual block mode Ctrl + v

V enters visual line mode

R enters replacement mode to replace in batches after the cursor, similar to Insert for text on Windows

Automatic completion of VIm keyword Ctrl + p / n in insert mode

On how to use the vi command in the linux system to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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