当前位置:网站首页>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 .
边栏推荐
- 【數字IC驗證快速入門】20、SystemVerilog學習之基本語法7(覆蓋率驅動...內含實踐練習)
- 8大模块、40个思维模型,打破思维桎梏,满足你工作不同阶段、场景的思维需求,赶紧收藏慢慢学
- Ctfshow, information collection: web10
- [Data Mining] Visual Pattern Mining: Hog Feature + cosinus Similarity / K - means Clustering
- 有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?
- 2. 堆排序『较难理解的排序』
- [target detection] yolov5 Runtong voc2007 data set
- 【數據挖掘】視覺模式挖掘:Hog特征+餘弦相似度/k-means聚類
- 众昂矿业:萤石继续引领新能源市场增长
- MySQL installation configuration 2021 in Windows Environment
猜你喜欢
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
2022年5月互联网医疗领域月度观察
2022 all open source enterprise card issuing network repair short website and other bugs_ 2022 enterprise level multi merchant card issuing platform source code
[quick start of Digital IC Verification] 29. Ahb-sramc (9) (ahb-sramc svtb overview) of SystemVerilog project practice
Niuke real problem programming - day14
Unity之ASE实现全屏风沙效果
2. Heap sort "hard to understand sort"
CTFshow,信息搜集:web8
CTFshow,信息搜集:web10
Ctfshow, information collection: web10
随机推荐
【深度学习】图像超分实验:SRCNN/FSRCNN
Pit avoidance: description of null values in in and not in SQL
【服务器数据恢复】某品牌StorageWorks服务器raid数据恢复案例
[quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)
CTFshow,信息搜集:web6
【数字IC验证快速入门】26、SystemVerilog项目实践之AHB-SRAMC(6)(APB协议基本要点)
银行需要搭建智能客服模块的中台能力,驱动全场景智能客服务升级
[make a boat diary] [shapr3d STL format to gcode]
“百度杯”CTF比赛 2017 二月场,Web:include
拜拜了,大厂!今天我就要去厂里
什么是数据泄露
Niuke real problem programming - day15
Write a ten thousand word long article "CAS spin lock" to send Jay's new album to the top of the hot list
CTFshow,信息搜集:web5
[deep learning] image hyperspectral experiment: srcnn/fsrcnn
PAT 甲级 1103 Integer Factorizatio
暑期安全很重要!应急安全教育走进幼儿园
2.Golang基础知识
【數據挖掘】視覺模式挖掘:Hog特征+餘弦相似度/k-means聚類
【數字IC驗證快速入門】26、SystemVerilog項目實踐之AHB-SRAMC(6)(APB協議基本要點)