当前位置:网站首页>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
边栏推荐
- Azure 开发者新闻快讯丨开发者6月大事记一览
- Tri rapide, index groupé, recherche de la plus grande valeur K dans les données
- HTA入门基础教程 | VBS脚本的GUI界面 HTA简明教程 ,附带完整历程及界面美化
- Mysql表数据比较大情况下怎么修改添加字段
- 2022 new test questions for safety management personnel of metal and nonmetal mines (small open pit quarries) and certificate examination for safety management personnel of metal and nonmetal mines (s
- 一篇文章带你入门vim
- HOOK Native API
- shell统计某个字符串最后一次出现的位置之前的所有字符串
- High paid programmers & interview questions series 63: talk about the differences between sleep (), yield (), join (), and wait ()
- Federal learning: dividing non IID samples by Dirichlet distribution
猜你喜欢

Mysql提取表字段中的字符串

Mysql表数据比较大情况下怎么修改添加字段

Gulang bilibilibili Live Screen Jackie

公司电脑强制休眠的3种解决方案

Heavy attack -- ue5's open source digital twin solution

C # basic learning (XIII) | breakpoint debugging

DC/DC变换器轻载时三种工作模式的原理及优缺点

Auto. JS learning notes 16: save to the mobile phone by project, instead of saving a single JS file every time, which is convenient for debugging and packaging

自定义MVC的使用

Visual HTA form designer htamaker interface introduction and usage, Download | HTA VBS visual script writing
随机推荐
Software testing skills, JMeter stress testing tutorial, transaction controller of logic controller (25)
可视化HTA窗体设计器-HtaMaker 界面介绍及使用方法,下载 | HTA VBS可视化脚本编写
Azure 开发者新闻快讯丨开发者6月大事记一览
F1C100S自制开发板调试过程
如果辨别我现在交易的外盘股指期货交易平台是否正规安全?
简单自定义mvc
Uniapp address translation latitude and longitude
Prompt learning a blood case caused by a space
Cmake tutorial series -05- options and variables
Intel hex, Motorola S-Record format detailed analysis
JS cross reference
在php中字符串的概念是什么
JS 互相引用的问题
Hands on in-depth learning notes (XV) 4.1 Multilayer perceptron
快速排序、聚簇索引、尋找數據中第k大的值
【实战技能】如何撰写敏捷开发文档
Multi card server usage
How to realize remote collaborative office, keep this strategy!
炒现货黄金的交易平台如何保障资金安全?
HTA入门基础教程 | VBS脚本的GUI界面 HTA简明教程 ,附带完整历程及界面美化