当前位置:网站首页>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 .
边栏推荐
- 【搞船日记】【Shapr3D的STL格式转Gcode】
- There is a cow, which gives birth to a heifer at the beginning of each year. Each heifer has a heifer at the beginning of each year since the fourth year. Please program how many cows are there in the
- Guangzhou Development Zone enables geographical indication products to help rural revitalization
- 什麼是數據泄露
- 2022年5月互联网医疗领域月度观察
- Stream learning notes
- Wechat applet 01
- CTFshow,信息搜集:web10
- What are the safest securities trading apps
- Unity's ASE achieves full screen sand blowing effect
猜你喜欢
Write a ten thousand word long article "CAS spin lock" to send Jay's new album to the top of the hot list
Ctfshow, information collection: Web3
CTFshow,信息搜集:web7
Win10 or win11 taskbar, automatically hidden and transparent
HW primary flow monitoring, what should we do
CTFshow,信息搜集:web3
Ctfshow, information collection: web1
Ctfshow, information collection: web13
2022 all open source enterprise card issuing network repair short website and other bugs_ 2022 enterprise level multi merchant card issuing platform source code
Briefly describe the working principle of kept
随机推荐
【服务器数据恢复】戴尔某型号服务器raid故障的数据恢复案例
PAT 甲级 1103 Integer Factorizatio
大表delete删数据导致数据库异常解决
Excerpted words
CTFshow,信息搜集:web14
2.Golang基础知识
【OBS】RTMPSockBuf_Fill, remote host closed connection.
【兰州大学】考研初试复试资料分享
MySQL installation configuration 2021 in Windows Environment
[quick start of Digital IC Verification] 26. Ahb-sramc of SystemVerilog project practice (6) (basic points of APB protocol)
[make a boat diary] [shapr3d STL format to gcode]
CTFshow,信息搜集:web2
2022全开源企业发卡网修复短网址等BUG_2022企业级多商户发卡平台源码
【數字IC驗證快速入門】20、SystemVerilog學習之基本語法7(覆蓋率驅動...內含實踐練習)
HW primary flow monitoring, what should we do
Unity之ASE实现卡通火焰
What is data leakage
What are PV and UV? pv、uv
Whether runnable can be interrupted
有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?