当前位置:网站首页>An article to get you started VIM
An article to get you started VIM
2022-06-30 03:05:00 【San Mao who likes to knock code】
List of articles
vi&vim
vi and vim The difference between , Simply put, they are all multimodal editors , The difference is vim yes vi Updated version of , It's not only compatible with vi All instructions , But also with some new features in it , For example, syntax highlighting , Visualization can be done not only in Terminal operation , It can also run on mac os On .
vim Concept
vim Is a text editor with multiple modes , Here are the three most commonly used modes .
- Command mode ( The default mode )
Control the movement of the screen cursor , character 、 Deletion of words and lines 、 Move copy a section and enter In insertion mode , Or enter In bottom line mode - Insertion mode
You can enter text only in insert mode , PressEsc keyYou can return to the command mode - Bottom line mode
File save exit , You can also replace files , Find string , List a series of operations such as line number , In command mode ,shift+:Can Enter this mode , The essence is to enter a colon .
View all vim Pattern command , Get into vim In bottom line mode Enter the following command help vim-modes
vim share 16 Patterns , It is divided into 6 This basic pattern and 6 An additional mode


vim Basic operation ( Mode switch + Save and exit )

grammar :vim file name
Be careful :vim command Enter into vim after , The default is In command mode , To switch to Insertion mode Before you can enter text
[ Command mode ] Switch to [ Insertion mode ]
Input a
Input i
Access o
That is to say, input a、i、o You can switch from command mode to insert mode
[ Command mode ] Switch to [ Bottom line mode ]
Press and hold at the same timeshift + :, It's essentially entering a colon , You can switch from the command mode to the bottom line mode[ Insertion mode or Bottom line mode ] Switch to Command mode
Whether it's in insert mode or bottom line mode, or you don't know which mode you're in , Direct mindless pressing
EscThat's all right.sign out vim And save files
Enter... In command mode:Enter bottom line mode
There are three letter options :w: preservation 、q: sign out 、!: mandatory- Save the file :
:w - Exit without saving :
q - Force save and exit :
wq! - Forced exit :
q - Force save :
w!
- Save the file :

vim Command mode operation summary
Move the cursor
Cursor movement : Left
h、 Nextj、 Onk、 RightlPosition the cursor left and right :
shift+^,shift+$, Left and right positioning ( Position the cursor directly on the... Of the current linecharacterLeftmost and rightmost )` White space characters do not countUp and down positioning :
shift+gGo to the last line 、ggGo to the first lineSpecify positioning :
n+shift+g,n Is a number that means location To Lines , such as 8+shift+g Go to the beginning of the eighth lineWord location :
wThe cursor is positioned at the beginning of the next word ,eThe cursor is positioned at the end of the next word ,bCursor positioning To the beginning of the last wordPosition back :
Numbers +lMove the cursor to the back of the current position of the current row n Characters , If it is6+lIt's moving backwards 6 CharactersPage turning :
ctrl+fMove the screen back one page ,ctrl+bMove screen forward one page ,ctrl+dThe screen moves back half a page ,ctrl+uMove the screen forward half a page
Delete text
x: Every time you press , Delete the first character at the cursor position[#x]: such as3xIndicates that after the position of the deletion cursor ( contain own ) Of 3 CharactersX: Capitalization X, Press once to delete a character in front of the cursor ( Not including myself )#X: Capitalization X, such as10XDelete the front of the cursor 10 Characters ( Not including myself )dd: Delete the line where the cursor is located#dd: Delete from the line where the cursor is located # That's ok ,, such as 4dd Delete from the current line 4 That's ok ( Include the line )
Copy cut paste text
yw: Copy the character from the cursor to the end of the word to the buffer ( Copy the letters of a word from the cursor position of the word , Generally, when encountering different types of characters, it will stop copying )#yw: Copy # A word into the buffer ( The distinction between words can be words or characters or Chinese , This may not be rigorous )yy: Copy the cursor Line to buffer#yy: Copy the cursor line back # That's ok , Including the current linep: Paste the characters of the buffer to the position of the cursor ( Be careful : All inyThe related copy commands must be the same aspCooperation ability Complete the copy and paste function )dd+p: Cut the current line of text
Replace words
r: Replace the character where the cursor is , such asr+6Is to replace the character of the cursor with 6R: Constantly replace the characters where the cursor goes , Know to pressEscKey up
Revocation and reinstatement of revocation
u: Immediately recall to the previous operation , Be similar to windows Of Ctrl+zCtrl+r: Undo restore , Return to the state before revocation
Case Toggle
shirt + ~: Replace the lowercase character of the cursor with the size , Replace size with lowercase
Bottom line mode command summary
shift + : Enter bottom line mode
According to the line Numbers
set nu: According to the line Numbers
set nonu: Cancel the line Numbers
Save and exit
w: preservation 、q: sign out 、!: mandatory , Can be used together
stay vim perform Linux command
!+[ command ]: Don't quit vim perform Linux command

Again ls Query whether there is successfully compiled code


Execute the successfully compiled code


vim Split screen
vs file name: Split screen
If the file doesn't exist , The command is created automatically , And save with the command , Exit without saving still Will not appear in the directory
Each split screen is a vim, All can be done vim Switching between multiple modes

ctrl + w: Split screen , The cursor switches between multiple screens
Multiple split screens can be switched with this command , Where the cursor is vim In the window
vim To configure
stay
/etc/below , A name is vimrc The file of , It is public in the system vim The configuration file , It works for all usersAnd in each user's home directory , You can create your own private configuration file , Name it
.vimrc
usevim .vimrcOpen the file to add some vim To configureFor example, display the line number
set nu
After this is configured, the line number will not be displayed in the bottom line mode
More configurations can be made by Baidu
because vim It's very cumbersome to configure , Some configurations also require the installation of plug-ins . You can use the boss in Githup Upper vim To configure , All you need is one command vim To configure
边栏推荐
- Cross domain, CORS, jsonp
- Compile a DLL without import table
- Use of Arthas
- mysqldump原理
- zabbix 触发器详解
- MySQL extracts strings from table fields
- The MariaDB database was found 12 hours late
- Intel-Hex , Motorola S-Record 格式详细解析
- Cmake tutorial series -04- compiling related functions
- Distributed file system fastdfs
猜你喜欢

HTA入门基础教程 | VBS脚本的GUI界面 HTA简明教程 ,附带完整历程及界面美化
![[live broadcast notes 0629] Concurrent Programming II: lock](/img/5c/42f5c9a9969b4d2bb950a7caac5555.png)
[live broadcast notes 0629] Concurrent Programming II: lock

Visual HTA form designer htamaker interface introduction and usage, Download | HTA VBS visual script writing

Raki's notes on reading paper: Leveraging type descriptions for zero shot named entity recognition and classification

F1c100s self made development board debugging process

Use compose to realize the effect of selecting movie seats by panning tickets

IDEA 远程调试 Remote JVM Debug

如何实现远程协同办公,收好这份攻略!

Wechat applet page Jump and parameter transfer

自定义JvxeTable的按钮及备注下$set的用法
随机推荐
mysqldump原理
How does native JS generate Jiugong lattice
The Oracle main program is deleted, but the data is on another hard disk. Can I import the data again?
Compile a DLL without import table
What kind of foreign exchange trading platform is regulated and safe?
How can redis+aop customize annotations to achieve flow restriction
华为面试题: 分糖果
Interrupt operation: abortcontroller learning notes
一篇文章带你入门vim
HTA入门基础教程 | VBS脚本的GUI界面 HTA简明教程 ,附带完整历程及界面美化
uniapp 地址转换经纬度
广播模块代码在autojs4.1.1版本运行正常,但在pro7.0版本上运行报错(未解决)
C # basic learning (XIII) | breakpoint debugging
福利抽奖 | 开源企业级监控Zabbix6.0都有哪些亮点
Utf8 error in Oracle migration of Jincang Kingbase database
Cmake tutorial series-01-minimum configuration example
问题记录:fel_lib.c:26:10: fatal error: libusb.h: 没有那个文件或目录
Use of Arthas
Visual HTA form designer htamaker interface introduction and usage, Download | HTA VBS visual script writing
行政路线编码 字母+数字的排序方式