当前位置:网站首页>Editor use of VI and VIM
Editor use of VI and VIM
2022-07-05 08:58:00 【Wanderer001】
Reference resources Editor -vi、vim Use - cloud + Community - Tencent cloud
Catalog
1、vi brief introduction
vi Editor yes Linux and Unix The most basic Text editor , Working in character In mode . Because you don't need a graphical interface ,vi It's a very efficient text editor . Although in Linux There are also many graphical interface editors available on , but vi In the system and Server management The functions in are those Graphic editor Incomparable .
vi Editor It is often referred to as vi, and vi again “Visual interface” For short . It's in Linux Status in the world is like Edit The program is in DOS It's the same . It can perform output 、 Delete 、 lookup 、 Replace 、 Block operations and many other text operations , And users can customize it according to their own needs , This is the other Edit the program Not available .
vi The editor is not a typesetting Program , It is not like Word or WPS That way, it's possible to 、 Format 、 Arrange paragraphs and other attributes , It's just a text editor . No menu , Only the command , And there are many orders .vi Yes 3 Basic working mode : Command line mode 、 Text input mode and last line mode .
Vim yes vi The enhanced , Than vi Easier to use .vi Almost all of your commands can be found in vim Upper use .
2、vi Working mode
vi There are three basic modes of work : Command mode 、 Text input mode 、 Last row mode .
vi Working mode
2.1、 Command mode
anytime , No matter what mode the user is in , Just press ESC key , Can make Vi Enter command mode ; We are shell Environmental Science ( The prompt is $) Lower input start Vi command , When you enter the editor , Also in this mode . In this mode , Users can enter all kinds of legal Vi command , For managing your own documents . Any character entered from the keyboard is interpreted as an edit command , If the input character is legal Vi command , be Vi After receiving the user's command, complete the corresponding action . But it should be noted that , The command entered is not displayed on the screen . If the input character is not Vi The legal order of ,Vi Will ring the alarm .
2.2、 Edit mode
Enter the insert command in command mode i( Insert current position )、a( Insert at the next position after the current position ) 、o( Insert... In the next line ) You can enter text input mode . In this mode , Any character entered by the user is vi Save it as file content , And show it on the screen . In the process of text input , If you want to go back to command mode , Key ESC that will do .
2.3、 Last row mode
In command mode , User presses “:” Key to enter the last line mode , here Vi In the last line of the display window ( It's usually the last line of the screen ) Display a “:” As a prompt for the last line mode , Wait for the user to enter the command . Most file management commands are executed in this mode ( Write the contents of the edit buffer to a file ). After the last command is executed ,Vi Automatically return to command mode .
If you want to change from command mode to edit mode , You can type commands a perhaps i; If you need to return from text mode , Then press Esc Press the key . Enter... In command mode “:” You can switch to the last line mode , Then type the command .
3、vi Basic manipulation
3.1、 Enter edit mode
command | meaning |
---|---|
i and I | i Insert... In front of the cursor ,I Insert at the beginning of line |
a and A | a Insert... After the cursor ,A Insert at end of line |
o and O | o Insert... On the next line below the line where the cursor is located ,O Insert... On the line where the cursor is located |
3.2、 Move the cursor
command | meaning |
---|---|
h | Move the cursor to the left |
j | Cursor down |
k | Move the cursor up |
l | Move the cursor to the right |
H、M、L | The cursor moves to the first line of the visible screen (H)、 Middle row (M)、 The last line (L) |
^ and $ | ^ Move to beginning of line ,$ Move to the end of the line |
G and gg | G The last line of the document ,gg The first line of the document |
ctrl+f、ctrl+b | Flip the screen forward 、 Flip the screen back |
ctrl+d、ctrl+u | Forward half 、 Half back |
{ and } | { Move up a section ,} Move back a bit |
w and b | Move a word forward , Move a word back |
3.3、 The delete command
command | meaning |
---|---|
X and x | x Delete the character after the cursor ,X Delete the character before the cursor , Contains cursor position characters |
dd and n dd | dd Delete the line ,5 dd Delete the specified number of rows |
d0 and D | d0 Delete all the contents of the line before the cursor ,D Delete all the contents of the line after the cursor is deleted , Contains cursor position characters |
dw | Delete the word where the cursor is located , Contains the characters of the position of the light table |
3.4、 Revocation order
command | meaning |
---|---|
u | Undo step by step |
ctrl + r | Counter cancellation |
3.5、 Repeat the order
command | meaning |
---|---|
. | Repeat the command of the last operation |
3.6、 Copy and paste
command | meaning |
---|---|
yy | and n yy and y$ y^ yy Copy the current row ,5 yy Copy 5 That's ok |
p | Paste a new line down at the cursor |
3.7、 Select text
command | meaning |
---|---|
v and V | v Select a single character ,V Select entire line |
<< and >> | After selecting the text , Indent left , Indent right |
3.8、 Search and replace
command | meaning |
---|---|
In command mode ,r and R | r Replace the current character ,R Replace the character after the cursor |
In last line mode ,/ + str | n Find the next one ,N Find the previous |
In last line mode ,%s/abc/123/g | Put all the abc Replace with 123 |
In last line mode ,1, 10s/abc/123/g | Put the first line to 10 Between lines abc Replace with 123 |
边栏推荐
猜你喜欢
容易混淆的基本概念 成员变量 局部变量 全局变量
Attention is all you need
[牛客网刷题 Day4] JZ35 复杂链表的复制
Programming implementation of subscriber node of ROS learning 3 subscriber
Introduction Guide to stereo vision (4): DLT direct linear transformation of camera calibration [recommended collection]
Programming implementation of ROS learning 5-client node
[code practice] [stereo matching series] Classic ad census: (4) cross domain cost aggregation
我从技术到产品经理的几点体会
C# LINQ源码分析之Count
生成对抗网络
随机推荐
The combination of deep learning model and wet experiment is expected to be used for metabolic flux analysis
Solution to the problems of the 17th Zhejiang University City College Program Design Competition (synchronized competition)
C [essential skills] use of configurationmanager class (use of file app.config)
[daiy4] copy of JZ35 complex linked list
生成对抗网络
Tips 1: Web video playback code
.NET服务治理之限流中间件-FireflySoft.RateLimit
My experience from technology to product manager
MPSoC QSPI Flash 升级办法
OpenFeign
Halcon Chinese character recognition
Wechat H5 official account to get openid climbing account
编辑器-vi、vim的使用
Introduction Guide to stereo vision (1): coordinate system and camera parameters
Characteristic Engineering
How many checks does kubedm series-01-preflight have
Illustrated network: what is gateway load balancing protocol GLBP?
RT-Thread内核快速入门,内核实现与应用开发学习随笔记
asp.net(c#)的货币格式化
[code practice] [stereo matching series] Classic ad census: (5) scan line optimization