当前位置:网站首页>Some tips of vim text editor
Some tips of vim text editor
2022-07-29 07:01:00 【hgswnsa】
List of articles
vim What is it? ?
vim Is a similar to vi The famous and powerful 、 Highly customizable text editor , stay vi Many features have been improved and added ,vim The focus of is the movement of the cursor 、 Mode switch 、 Delete 、 Search and replace 、 Copy 、 Paste 、 Use of revocation order .
vim Three models of
Command mode : You can enter the shortcut key for some operations ( Delete row 、 Copy line 、 paste row 、 Move the cursor, etc )
The input mode : You can edit the contents of the file
Last row mode : You can type a command at the end to operate on the file ( Search for 、 Replace 、 preservation 、 sign out 、 revoke 、 Highlight, etc )
The following figure shows the switching between the three modes and what can be done in various modes

vim How to open a file
vim file name : Open the specified file
vim + Numbers file name : Open the specified file , And move the cursor to the specified line
vim +/ key word file name : Open the specified file , And highlight the keywords
vim file name 1 file name 2 file name 3: Open three files at the same time , How to switch files will be explained in detail below
perform vim +2 aaa command , The effect is as follows

perform vim +/aaa aaa command , The effect is as follows

Use vim Open multiple files , Switch files in last line mode
Enter... In last line mode files , And press enter.
%a Represents the currently open file ,# Represents the last open file 
File switching
1、 Enter... In last line mode open file name Such as open bbb, And press enter.
2、 Switch up / Next file
Switch to the previous file , Enter... In last line mode bp , Switch to the next file , Enter... In last line mode bn
vim The way out
Enter... In the last line mode wq or q or wq! or q!
wq: Exit and save
q: Exit without saving
wq!: Force exit and save
q!: Force exit without saving
Command mode
This mode is the first one you see when you open a file ( Open the file to access )
Cursor movement
1、 Move the cursor to the beginning of the line Key :shift+6 ( Pay attention to the number of the main keyboard , It's not a number on the keypad )
2、 Move the cursor to the end of the line Key :shift+4
3、 The cursor moves to the first line Key :gg
4、 The cursor moves to the last line Key :G
5、 Flip screen Flip up the screen :ctrl+b or PgUp
Flip screen down :ctrl+f or PgDn
Copy operation
1、 Copy the line where the cursor is Key :yy, Paste : Press... Where you want to paste p key
2、 Subject to the behavior of the cursor ( Contains the current line ), Copies down the specified number of lines Key : Numbers yy, Paste :p
3、 Visual replication Key :ctrl+v Then press the up, down, left and right arrow keys to select the block to be copied , Press down yy Key to copy , Finally press p Insert
shear / Delete
1、 shear / Deletes the line where the cursor is located Key :dd ( Move the next line up after deleting )
Be careful :dd Strictly speaking, it is a cutting command , But if you cut and don't paste, it will be deleted
2、 shear / Delete the cursor ( Contains the current line ), Cut down / Delete the specified row Key : Numbers dd( Move the next line up after deleting )
3、 shear / Delete the current line of the cursor , After deletion, the next line does not move up Key :D
revoke / recovery
1、 revoke : Input :u perhaps u(u namely undo)
2、 recovery :ctrl+r ( Cancel the previous cancellation )
Expand : The rapid movement of the cursor
1、 Quickly move the cursor to the specified line Key : Numbers G
2、 Based on the current cursor, up / Move down the n That's ok Key : Numbers ↑, Numbers ↓
3、 Take the current cursor as the left / To the right n character Key : Numbers ←, Numbers →
4、 Fast moving mode in last line mode : Move to the specified line
Enter English in command mode “:” Enter last line mode , Then enter the number , Press enter
The input mode
Input i or a Enter input mode
1、 Start inserting in front of the character where the cursor is Key :i
2、 Insert after the character of the cursor Key :a
Last row mode
1、 file save as Key :w route
2、 Call external command Key :! External command ( Such as !ls)
3、 Search or find Key :/ key word
Switch to... In search results / Next result Key :N/n
4、 Replace
Replace only the first match in the line where the cursor is located Key :s/ Original content / Target content
Replace all matching contents in the line where the cursor is located Key :s/ Original content / Target content /g
Replace the first match of all lines Key :%s/ Original content / Target content /
Replace all matching contents of all lines Key :%s/ Original content / Target content /g
% Represents the entire document ,g Global representation global
5、 According to the line Numbers Key :set nu(nu namely number)
Don't show line numbers Key :set nonu
Expand : How to ensure that the pasted text remains the original style
First enter set paste, Then input i Enter input mode , At this time, a “paste” Paste tips , Then paste the text , You can keep the original style , No mess
边栏推荐
- 吴恩达老师机器学习课程笔记 01 引言
- IO stream - file - properties
- N2 interface of 5g control plane protocol
- 5g service interface and reference point
- 【冷冻电镜】Relion4.0——subtomogram教程
- 吴恩达老师机器学习课程笔记 00 写在前面
- SSH免密登录-两台虚拟机建立免密通道 双向信任
- 'function VTable for error: undefined reference to... 'cause and solution of the problem
- 【冷冻电镜】RELION4.0之subtomogram对位功能源码分析(自用)
- Teacher Cui Xueting's course notes on optimization theory and methods 00 are written in the front
猜你喜欢

王树尧老师运筹学课程笔记 07 线性规划与单纯形法(标准型、基、基解、基可行解、可行基)

Jetpack Compose 中的键盘处理

Leetcode-592: fraction addition and subtraction

IDEA找不到Database解决方法

IDEA中实现Mapper接口到映射文件xml的跳转

新同事写了几段小代码,把系统给搞崩了,被老板爆怼一顿!

Thread - thread safety - thread optimization

The core of openresty and cosocket

How to write controller layer code gracefully?

【冷冻电镜|论文阅读】A feature-guided, focused 3D signal permutation method for subtomogram averaging
随机推荐
吴恩达老师机器学习课程笔记 00 写在前面
模拟卷Leetcode【普通】150. 逆波兰表达式求值
5g service interface and reference point
【C语言刷LeetCode】1054. 距离相等的条形码(M)
Database multi table query joint query add delete modify query
Ali gave several SQL messages and asked how many tree search operations need to be performed?
【解决方案】ERROR: lib/bridge_generated.dart:837:9: Error: The parameter ‘ptr‘ of the method ‘FlutterRustB
关于SQL Server语句入门级应用阶段性学习——找工作必备(一)
王树尧老师运筹学课程笔记 05 线性规划与单纯形法(概念、建模、标准型)
vim文本编辑器的一些使用小技巧
【CryoEM】FSC, Fourier Shell Correlation简介
Jetpack Compose 中的键盘处理
Actual combat! Talk about how to solve the deep paging problem of MySQL
模拟卷Leetcode【普通】081. 搜索旋转排序数组 II
数据库系统概述
【冷冻电镜】Relion4.0——subtomogram教程
2D cartoon rendering - advanced skills
ECCV 2022丨轻量级模型架ParC-Net 力压苹果MobileViT代码和论文下载
【论文阅读】TomoAlign: A novel approach to correcting sample motion and 3D CTF in CryoET
网上传说软件测试培训真的那么黑心吗?都是骗局?