当前位置:网站首页>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
边栏推荐
- Use compose to realize the effect of selecting movie seats by panning tickets
- Servlet interview questions
- 中断操作:AbortController学习笔记
- 2. 成功解决 BUG:Exception when publishing, ...[Failed to connect and initialize SSH connection...
- The Oracle main program is deleted, but the data is on another hard disk. Can I import the data again?
- 个人PC安装软件
- How can redis+aop customize annotations to achieve flow restriction
- Problem record: FEL_ lib. c:26:10: fatal error: libusb. h: There is no such file or directory
- OP-diode-限制摆幅
- Summary of PHP test sites encountered in CTF questions (I)
猜你喜欢

可视化HTA窗体设计器-HtaMaker 界面介绍及使用方法,下载 | HTA VBS可视化脚本编写

F1C100S自制开发板调试过程

Idea remote debugging remote JVM debug

中断操作:AbortController学习笔记

How to switch ipykernel to a different CONDA virtual environment in jupyterlab?

LeetCode 3. Longest substring without duplicate characters

Raki's notes on reading paper: named entity recognition as dependency parsing

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

发现mariadb数据库时间晚了12个小时

Distributed file storage system fastdfs hands on how to do it
随机推荐
New edition of diazotization process in 2022 and analysis of diazotization process
怎样的外汇交易平台是有监管的,是安全的?
Azure 开发者新闻快讯丨开发者6月大事记一览
c#控制台格式化代码
Data set preparation and arrangement
Raki's notes on reading paper: neighborhood matching network for entity alignment
Cmake tutorial series-01-minimum configuration example
Lua 基础知识
(图论) 连通分量(模板) + 强连通分量(模板)
How can redis+aop customize annotations to achieve flow restriction
Idea remote debugging remote JVM debug
Cmake tutorial series -02- generating binaries using cmake code
Use compose to realize the effect of selecting movie seats by panning tickets
What is the concept of string in PHP
oracle怎么设置密码复杂度及超时退出的功能
Série de tutoriels cmake - 02 - génération de binaires à l'aide du Code cmake
Formal and actual parameters, value passing and address passing
Software testing skills, JMeter stress testing tutorial, transaction controller of logic controller (25)
F1C100S自制开发板调试过程
C # basic learning (XIII) | breakpoint debugging