当前位置:网站首页>15. Using the text editing tool VIM
15. Using the text editing tool VIM
2022-07-07 15:37:00 【51CTO】
VIM Use format
vim [option] ...file ...
Common options
+# After opening the file , Place the cursor at # That's ok
+/pattern Let the cursor be at the first pattern The first line of the matched line
-b file Binary open file
-d file1 file2 ... Compare multiple files , amount to vimdiff
-m file Read only open file
-e file Go straight into ex Pattern , amount to ex file
-y file easy mode Look directly at the operation documents
VIM Three models
vim There are three patterns ( Command or normal mode 、 Insert or edit mode 、 Extended command mode )
The three need to be converted
Extended command mode
In command mode , Under English characters , Hold down shift+:( Input :) Enter extended command mode , The bottom will appear :
Extended command basic command
w Write save
wq Write save exit
x Equate to wq
X encryption
q sign out
q! Forced exit without saving
r filename Read the contents of the file into the current file
w filenamen Write the current file to another file ( Save as )
!commad Carry out orders
r!command Read in the output of the command
Address delimitation
Format : Start , end
# Specifically # That's ok
#,# From left side # Start # end
#,+# from # Start ,#+# end
. Current row
$ The last line
% The full text , amount to 1,$
/pattern/ Look down from the current line to find a match pattern first line
/pattern1/,/pattern2/ From the first time pattern1 From the beginning of the matching line to the first time pattern2 End of match line
Address delimitation followed by an edit command
y Copy
d Delete
w file Save the specified file as
r file Inserts everything in the specified file at the specified location
Find and replace
s/ What to look for / Replace with / Modifier
explain : If there is no modifier behind , Only match the search content once to replace , We need to add g Modifier , Make a global replacement ; If you find that the content contains /, Other delimiters can be used ; Such as [email protected]/[email protected]/[email protected] The command uses @ Replace / Separator
Modifier
i Ignore case
g Global replacement
gc Global replacement , Ask... Before each replacement
customized vim Working characteristics of
overall situation /etc/vimrc personal ~/.vimrc
Set line number display set number Abbreviation set nu
Cancel line number display set nonumber
Ignore character case and enable set ignorecase Abbreviation set ic
Cancel ignoring case set noic
Automatic indentation set autoindent Abbreviation set ai
Cancel auto indent set noai
Copy the reserved format set paste
Cancel copy retention format set nopaste
Show tab And line breaks set list Ban set nolist
Highlight search set hlsearch Ban set nohlsearch
Syntax highlighting syntax on Ban syntax off
File format windows set fileformat=dox unix set fileformat=unix(set ff=dos|unix)
tab Use space instead of set expandtab (set et Default 8 A space ) Ban set expandtab
Appoint tab How many spaces to replace set tabstop=#
Set the text width set textwidth=# set wrapmatgin=#
Set the marking line set cursorline (set cul) Ban set nocursorline
encryption set key=password Ban set key=
Command mode
Command mode is also called normal Pattern
The cursor jumps
h: Left L: Right j: Next k: On
#h/l/j/k: Jump # Characters
w: The first part of the next word
e: The end of the next word
b: Current word header
#w/e/b ditto
H: The first page M In the middle of the page L Bottom of page
zt Move the cursor to the top of the current screen
zz Move the cursor to the middle of the current screen
zb Move the cursor to the bottom of the current screen
^ Non white space characters at the beginning of the line 0 Head of line $ At the end of the line
#G Jump to the first place # That's ok G The last line 1G perhaps gg first line
ctrl+f Turn the tail ctrl+b Turn the first screen ctrl+d The tail half screen ctrl+u First half screen
Character editing
x Delete the character at the cursor #x Delete cursor start x Characters xp Exchange the position of the character that the cursor is in and the character after it
~ Convert case J Delete line break after current line
Replace the command
r Replace only one character at the cursor R Switch to replace Pattern , Press esc You can go back to command mode
The delete command
d The delete command
d$ Delete to end of line d^ Delete to the beginning of the line
dd Cut cursor line
#dd Multi row deletion
D: Deleting from the current cursor position to the end of the line is equivalent to d$
Copy command
y y$ y^ Same as above
Paste command
p Paste it behind the target , If yes , Under the line where the cursor is located
P Same as small p contrary
Change the order
c: Switch to insert mode after deletion c$ c^ cc #cc etc.
lookup
/pattern Find down
?pattern Upward search
n In the same direction as the command
N Against the command
Undo change
u: Undo recent changes #u It's better to undo many times before
U Undo all changes in the current cursor line
Advanced usage
0y$ ( First of all ,y Start copying ,$ To the end of the line )
100ilgw Input 100 Time lgw
di“ Delete “” Content between
yi( Copy () Content between
vi[ The cursor is on [] Between , Choose [] Content between
dtx Delete the character until it meets the first after the cursor x character
ytx Copy the character until the first one after the cursor x character
Visualization mode
At the end there is “--visual--” instructions , In visual mode
Allow text blocks to be selected
v character-oriented
V Facing the whole line
ctrl-v Facing the block
Insert at the beginning of all lines # crtl+v --- G---I---#---esc
Multi window mode
vim -o|O file1 file2
-o Split horizontally or up and down -O Vertically or left and right
Switch between windows ctrl+w
crtl+w,s Horizontal segmentation , Split up and down ctrl+w,v Vertical segmentation , Left and right split screen
ctrl+w,q Cancel adjacent windows ctrl+w,o Cancel all windows
:wqall sign out
Edit binary
Open the file in binary mode
vim -b file
The extension command %!xxd convert to 16 Base number %!xxd -r Return binary .
more vim Please find out how to use it on the Internet .
边栏推荐
- Ctfshow, information collection: web12
- 什么是数据泄露
- PAT 甲级 1103 Integer Factorizatio
- [follow Jiangke University STM32] stm32f103c8t6_ PWM controlled DC motor_ code
- Concurrency Control & NoSQL and new database
- [understanding of opportunity -40]: direction, rules, choice, effort, fairness, cognition, ability, action, read the five layers of perception of 3GPP 6G white paper
- Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
- Comparable and comparator of sorting
- Use cpolar to build a business website (2)
- CTFshow,信息搜集:web3
猜你喜欢
【搞船日记】【Shapr3D的STL格式转Gcode】
Unity's ASE achieves full screen sand blowing effect
[Data Mining] Visual Pattern Mining: Hog Feature + cosinus Similarity / K - means Clustering
【兰州大学】考研初试复试资料分享
【数字IC验证快速入门】24、SystemVerilog项目实践之AHB-SRAMC(4)(AHB继续深入)
什么是数据泄露
[make a boat diary] [shapr3d STL format to gcode]
8大模块、40个思维模型,打破思维桎梏,满足你工作不同阶段、场景的思维需求,赶紧收藏慢慢学
CTFshow,信息搜集:web1
[deep learning] image hyperspectral experiment: srcnn/fsrcnn
随机推荐
[deep learning] semantic segmentation experiment: UNET network /msrc2 dataset
MongoDB数据库基础知识整理
Oracle控制文件丢失恢复归档模式方法
Jacobo code coverage
简述keepalived工作原理
最安全的证券交易app都有哪些
2.Golang基础知识
从 1.5 开始搭建一个微服务框架链路追踪 traceId
Introduction of mongod management database method
CTFshow,信息搜集:web9
暑期安全很重要!应急安全教育走进幼儿园
CTFshow,信息搜集:web1
[follow Jiangke University STM32] stm32f103c8t6_ PWM controlled DC motor_ code
Integer learning
【兰州大学】考研初试复试资料分享
[quick start of Digital IC Verification] 20. Basic grammar of SystemVerilog learning 7 (coverage driven... Including practical exercises)
微信小程序 01
Guangzhou Development Zone enables geographical indication products to help rural revitalization
Pat grade a 1103 integer factorizatio
CTFshow,信息搜集:web2