当前位置:网站首页>VI editor common commands
VI editor common commands
2022-07-22 06:51:00 【I am often autistic】
vi Editor as Linux The most widely used text editor under , It is almost used in our daily work vi Editor .
vi The editor has three modes of operation : Command mode 、 Insertion mode 、 Last row mode .
1、 Command mode (command mode)— Carry out orders
In this mode , You can enter commands to perform many functions . Control the movement of the screen cursor , character 、 The deletion of words or lines , Move to copy a section and enter Insert mode Next , Or to last line mode.
2、 The input mode (Insert mode)— Input text
vi When running , Usually in command mode , Type the following command You can make vi Exit command mode , Enter input mode :I(i)、A(a)、O(o).
3、 Last row mode (last line mode)— Execute pending command
Save or exit a file vi, You can also set the editing environment , Like looking for Strings 、 List line numbers …… etc. . But we usually use vi Simplify it into two patterns , Is to put the last line mode (last line mode) It's also in command line mode command mode).
Switching of three modes :
Command mode <-------> Insertion mode
We use vi Open a file , The default mode is command mode , type ’a’ or ’i’ It goes into insert mode , Press... In insert mode Esc Key returns to the command mode .
Command mode <-------> Last row mode
Type ’:’ You can enter the last line mode , Press... In last line mode Esc Key returns to the command mode .
Insertion mode <==> Last row mode
In insert mode, you want to enter the last line mode , Press first Esc Key to enter command mode , Retype ’:’ You can enter the last line mode
In the last line mode, you want to enter the insert mode , Press first Esc Key to enter command mode , Retype ’a’ or ’i’ It goes into insert mode
Command mode :
Operation command | effect |
---|---|
i | Enter insertion mode |
a | Move the cursor to the right of the current position , And enter insertion mode |
o | Add a new line next to the line where the cursor is located , And enter insertion mode |
O | Add a new line on the line where the cursor is located , And enter insertion mode |
I | Position the cursor at the beginning of the line , And enter insertion mode |
A | Position the cursor at the end of the line , And enter insertion mode |
u | Undo the last operation |
U | Undo all operations |
dd | Delete line with cursor |
ndd(n Representation number ) | The first line of the cursor line , Delete n That's ok |
x | Delete the character where the cursor is |
~ | Change the case of the current cursor character ( Capitalize to lowercase , Lowercase to uppercase ) |
dw | Delete all characters from the current character to the end of the word |
yy | Copy the current cursor line |
nyy | Copy n That's ok ( Below the current cursor n That's ok ) |
yw | Copy the cursor position to the end of the word ( Do not include spaces ) Content to vi Buffer zone , It's equivalent to copying a word |
nyw | Copy n Word |
l( Lowercase L) | The cursor moves right |
nl | The cursor moves right n Characters |
h | The cursor moves left |
nh | The cursor moves left n Characters |
j | The cursor moves down |
nj | The cursor moves down n Characters |
k | The cursor moves up |
nk | The cursor moves up n Characters |
G | Move the cursor to the end of the file |
gg | Move the cursor to the beginning of the file |
w | Move the cursor to the beginning of the next word |
e | Move the cursor to the end of the current or next word |
b | Move the cursor to the beginning of the current or next word |
0( Numbers 0) | Move cursor to the beginning of line |
$ | Move the cursor to the end of the line |
n+ | Move the cursor down n That's ok |
n- | Move the cursor up n That's ok |
nG | Position the cursor to the second n The beginning of a row |
n$ | Move the cursor down n Line and place at the end of the line |
H | Move the cursor to the top line of the screen |
L | Move the cursor to the bottom line of the screen |
M | Move the cursor to the middle line of the current screen |
u | Undo the last operation |
U | Undo all operations |
Last row mode :
Operation command | effect |
---|---|
:w | Save the file |
:q | sign out vi Editor |
:q! | Forced exit vi Editor ( Do not save ) |
:set number | According to the line Numbers |
:set nonumber | Cancel line number display |
:set readonly | Set file read-only |
:s/old/new | Replace the first string in a line old For the new string new |
:s/old/new/g | Replace all strings in one line old For the new string new |
:m,ns/old/new/g | use new Replacement section m To the first n All right old |
:%s/old/new/g | use new Replace all old |
:m,nd | Delete the first m To n The content of the line |
:m,ny | Copy No m Go to the first place n The content of the line |
:n | Move the cursor to n That's ok |
:wq | Save file and exit vi Editor |
:w filename | Save specified file |
边栏推荐
- One click free download of foreign documents
- DOM系列之DOM事件流
- QSqlDatabase: QMYSQL driver not loaded的解决方案
- application.yml 和 application.propertise 配置不生效
- 【数学基础】 foundation of mathematics :NPC问题
- 封装微信支付宝脱敏
- [iccv 2019] acnet: using asymmetric convolution blocks to enhance CNN's convolution kernel skeleton
- 吉时利Keithley软件2400|2440|2450|2460|2461|2470 NS-SourceMeter源表软件
- Abstract classes and interfaces
- OSPF实验演示(Huawei路由器设备配置)
猜你喜欢
QT—图形视图
Leetcode 1217 playing chips [greedy] the leetcode road of heroding
HTC手机如何进行官方解锁Unlock
U++ learning note component and collision
UE4 学习笔记 CheckBox替代button + image
Deeply understand the principle of Redux Middleware
DOM系列之DOM事件流
QSqlDatabase: QMYSQL driver not loaded的解决方案
深入理解Redux中间件的原理
【ICCV 2019】ACNet: 使用非对称卷积块增强CNN的卷积核骨架
随机推荐
UE4 学习笔记 CheckBox替代button + image
echart的markArea遇到的坑啊为什么不是按照我设置的时间来显示的区间呢
DOM系列之事件对象
U++ 学习笔记 悬浮Actor
LeetCode 1217 玩筹码[贪心] HERODING的LeetCode之路
【MySQL和数据库】MySQL & database 第七章:视图的学习
idea 改变字体大小
NI LABVIEW 2019安装教程,ATECLOUD免安装可在线使用
7.15周学习总结
吉利星瑞产品力再升级,增加文化IP联动,是否值得买?
application.yml 和 application.propertise 配置不生效
还在用Unity开发游戏?那你就out了,试试用Unity做一个答题系统吧
吉时利Keithley软件2600系列2635B|2636B|2651A|2657A NS-SourceMeter源表软件
QT—图形视图
PLC 模糊控制系列之高斯型隶属函数指令
QT图形界面初学者项目 - 无人机群作战仿真模拟
Keithley software 2600 series 2611b | 2612b | 2614b | 2634b ns SourceMeter source table software
PHP, TP5 keywords, word segmentation, fuzzy query and sorting according to query conditions
232. 用栈实现队列(简单)
剑指 Offer 17. 打印从1到最大的n位数(大数问题)