当前位置:网站首页>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 |
边栏推荐
- Blogger article navigation (classified, real-time update, permanent top)
- AdaBoost use
- Causes and appropriate analysis of possible errors in seq2seq code of "hands on learning in depth"
- Halcon shape_ trans
- [Niuke brush questions day4] jz55 depth of binary tree
- Solution to the problem of the 10th Programming Competition (synchronized competition) of Harbin University of technology "Colin Minglun Cup"
- nodejs_ 01_ fs. readFile
- Codeforces Round #648 (Div. 2) D. Solve The Maze
- Halcon color recognition_ fuses. hdev:classify fuses by color
- Applet (use of NPM package)
猜你喜欢

IT冷知识(更新ing~)

Count of C # LINQ source code analysis

混淆矩阵(Confusion Matrix)

Shift operation of complement

Redis实现高性能的全文搜索引擎---RediSearch
![Rebuild my 3D world [open source] [serialization-1]](/img/74/b6253845b43bc18f425d57695fba7c.jpg)
Rebuild my 3D world [open source] [serialization-1]

资源变现小程序添加折扣充值和折扣影票插件

AUTOSAR从入门到精通100讲(103)-dbc文件的格式以及创建详解

Typescript hands-on tutorial, easy to understand

Programming implementation of subscriber node of ROS learning 3 subscriber
随机推荐
Codeforces round 684 (Div. 2) e - green shopping (line segment tree)
深度学习模型与湿实验的结合,有望用于代谢通量分析
我从技术到产品经理的几点体会
Typescript hands-on tutorial, easy to understand
[code practice] [stereo matching series] Classic ad census: (6) multi step parallax optimization
Latex improve
Applet (global data sharing)
Meta tag details
golang 基础 —— golang 向 mysql 插入的时间数据和本地时间不一致
golang 基础 ——map、数组、切片 存放不同类型的数据
Infix expression evaluation
File server migration scheme of a company
Ecmascript6 introduction and environment construction
Introduction Guide to stereo vision (6): level constraints and polar correction of fusiello method
微信H5公众号获取openid爬坑记
皮尔森相关系数
How many checks does kubedm series-01-preflight have
Array, date, string object method
np.allclose
kubeadm系列-00-overview