当前位置:网站首页>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 |
边栏推荐
猜你喜欢
Beautiful soup parsing and extracting data
Introduction Guide to stereo vision (4): DLT direct linear transformation of camera calibration [recommended collection]
Introduction Guide to stereo vision (6): level constraints and polar correction of fusiello method
生成对抗网络
[code practice] [stereo matching series] Classic ad census: (6) multi step parallax optimization
[technical school] spatial accuracy of binocular stereo vision system: accurate quantitative analysis
Blogger article navigation (classified, real-time update, permanent top)
Summary and Reflection on issues related to seq2seq, attention and transformer in hands-on deep learning
Codeworks round 639 (Div. 2) cute new problem solution
Introduction Guide to stereo vision (2): key matrix (essential matrix, basic matrix, homography matrix)
随机推荐
[牛客网刷题 Day4] JZ35 复杂链表的复制
编辑器-vi、vim的使用
It cold knowledge (updating ing~)
Mathematical modeling: factor analysis
Bit operation related operations
Ros-11 common visualization tools
C [essential skills] use of configurationmanager class (use of file app.config)
RT thread kernel quick start, kernel implementation and application development learning with notes
Redis implements a high-performance full-text search engine -- redisearch
某公司文件服务器迁移方案
嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!
ROS learning 4 custom message
Return of missing persons
C#图像差异对比:图像相减(指针法、高速)
Configuration and startup of kubedm series-02-kubelet
kubeadm系列-00-overview
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition
Use arm neon operation to improve memory copy speed
ABC#237 C
Basic number theory - factors