当前位置:网站首页>VIM basic configuration and frequently used commands
VIM basic configuration and frequently used commands
2022-07-06 21:14:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
vim Advantages and application scenarios
vim The advantages of pure text editing and Linux The perfect fusion provides the command line . It can only be assumed that ssh to server To operate , Then this kind of situation can only use vim 了 .vim It is also one of the most powerful general text editors , For scenarios where different texts need to be edited ,vim It is also quite advantageous . therefore , Master vim The basic use of is still very necessary .
vim Is in vi On the basis of many new features .gvim Is to vim Add the graphic front end . Suppose that Windows Next use vim, Be able to install the latest gvim.
Here is a main vimrc The configuration file . No matter what plug-ins are not configured , Just changed the theme to its own evening Dark theme . The font is changed to Consolas Equal width font . And the line number . Indent , Search and other basic settings . And the key mapping is done <ESC> -> ii,i It was originally to switch to insert mode , High speed double click i, Then switch back to normal The model is easy .
- Linux In general, users home Create a folder .vimrc File changes . Instead of changing /etc/vim Global configuration under folder , Affect all users .
- Windows in vimrc be located C:\Program Files (x86)\Vim Under the folder . The name is _vimrc, Suppose it is installed everything , Search directly vimrc One step to locate .
vim Configuration file for vimrc
"-----------------------------------------------------------------------------------
:imap ii <Esc> " Key mapping <ESC> -> ii
" appearance
colorscheme evening " Configure color theme
set guifont=Consolas:h12 " Set font and size
set number " According to the line Numbers
set guioptions-=T " Hide the toolbar
set ruler " Open the status bar ruler
set cursorline " Highlight current line
set syntax=on " Syntax highlighting
set showmatch " Highlight the matching brackets
set matchtime=3 " Match the highlighted time of brackets ( Company :0.1s)
set scrolloff=10 " Keep the cursor at the bottom of the screen 10 That's ok ( The cursor is at the bottom of the screen and looks very uncomfortable )
set lines=35 columns=118 " Size at startup
:winpos 177 51 " Position when starting
" Search for
set ignorecase smartcase " Search ignores uppercase and lowercase , But it is still sensitive to uppercase and lowercase when there are capital letters
set hlsearch " Highlight search
set incsearch " Incremental search , Highlight character by character
" operation
set clipboard+=unnamed " Shared clipboard
set showcmd " The input command is displayed
set iskeyword+=_,$,@,%,#,- " Words with symbols such as the following should not be cut by newline
set noexpandtab " No space is needed to replace Tab (makefile It is often used Tab Of )
set tabstop=4 " Tab Width of key
set shiftwidth=4 " Row stagger width
set mouse=a " Mouse available
set autoindent " Inherit the indent of the previous line . It is especially suitable for multi line staring
" Backup
set confirm " Not saved or just read , Pop up confirmation
set nobackup " Do not generate backup files
setlocal noswapfile " No generation swap file
set bufhidden=hide " When buffer Hidden when discarded
set noerrorbells " No warning sound
" decode
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936
vim Frequently used commands
# efficiency
. # Repeat recent text operations
# file
:q # sign out q->quit
:w # preservation w->write
:q! # Force exit without saving
:wq # Exit after saving
ZZ # Exit after saving , Same as :wq
# Cursor movement
hjkl # The most important thing is left, bottom, top and right . Move a character
zz # The cursor moves to the middle of the screen
w # Move a word forward . The cursor stops at the beginning of the word
b # Move a word back , The cursor stops at the beginning of the word
e # Same as w, The cursor stops at the end of the word
ge # Same as b, The cursor stops at the end of the word
0 # The first character on the line ( Same as <HOME> key )
^ # The first non blank character of the line
$ # Move to end of line ( Same as <END> key )
gg # Move to header
G # Move to end of file
:n # Jump to the first place n That's ok
fx # After moving to the cursor, the first one is x The characters of find
Fx # Same as f, Reverse shift
Ctrl+d # Scroll down half screen
Ctrl+u # Scroll up half screen
Ctrl+f # Scroll down half screen
Ctrl+b # Scroll up half screen
% # Jump to paired parentheses ( Regular use )
( # Move to the beginning of the current sentence
) # Move to the beginning of the next sentence
H # Move the top of the page H->High
M # Move the middle of the page M->Middle
L # Move the bottom of the page L->Low
# lookup
/test # lookup text ,( Remember to use regular expressions ), then n Down . N Up n->next
?test # lookup text . reverse
* # Look down for the same word as the cursor
# # Look up for the same word as the cursor
:nohlsearch # Turn off the currently highlighted result ( Input :noh Press down <Tab> key You can take the initiative to complete )
# Replace
ra # Replace the current character with a , r->replace
:%s/old/new/g # Replace all matches in the full text g->global
:%s/old/new/ # Replace all lines with the first match
:s/old/new/g # Replace the current line to match all
:s/old/new/ # Replace the first match in the current line
# Insert
a # Insert after current position a->append
A # Insert at end of current line
i # Insert... In the current position i->insert
I # Insert at the beginning of the current line
o # Insert one of the rows after the current row
O # Insert a row before the current row
s # Delete cursor character , And enter insertion mode
S # Delete line with cursor , And enter insertion mode
# Choose
v # From the current position of the cursor , Where the cursor passes will be selected , Then click on the v end ( be similar <shift>+ Direction construction ) v->view Visual Modes
V # Start from the current line of the cursor , The lines that the cursor passes through will be selected , Then click on the V end
# Delete
d # Delete selected ( The deleted content can be pasted into the buffer , It's equivalent to cutting ) d->delete
x # Delete the current character
3x # Delete the current cursor three characters backward (vim After frequent use < Numbers >+< command > Combine )
dd # Delete current row
dw # Delete the character where the cursor is located to the beginning of the next word dw -> delete word
d$ # Delete the current character to the end of the line %-> Regular is the end of the line
3d # Delete the first three lines of the current line
J # Merge two lines ( That is, delete the line break at the end of the current line ) J->join
# revoke
u # revoke u->undo
U # Undo the operation on the positive line
Ctrl+r # Reinstatement revocation
# Copy and paste
y # Copy selected
yy # Copy the current row
p # Paste after the current cursor . Suppose you copy one line and paste it to the next line p-paste
P # Paste in front of the current cursor
ddp # Swap the current line and the next line ( Clever use of cutting and pasting )
xp # Swap the current character with the next
Copyright notice : This article is the original article of the blogger , Blog , Do not reprint without permission .
[http://blog.csdn.net/thisinnocence]
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117090.html Link to the original text :https://javaforall.cn
边栏推荐
- Nodejs教程之Expressjs一篇文章快速入门
- Data Lake (VIII): Iceberg data storage format
- 【OpenCV 例程200篇】220.对图像进行马赛克处理
- 数据湖(八):Iceberg数据存储格式
- Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
- Math symbols in lists
- How to turn a multi digit number into a digital list
- Nodejs教程之让我们用 typescript 创建你的第一个 expressjs 应用程序
- Mtcnn face detection
- Spiral square PTA
猜你喜欢
性能测试过程和计划
SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
PHP saves session data to MySQL database
ICML 2022 | Flowformer: 任务通用的线性复杂度Transformer
监控界的最强王者,没有之一!
MLP (multilayer perceptron neural network) is a multilayer fully connected neural network model.
[MySQL] basic use of cursor
Pycharm remote execution
967- letter combination of telephone number
968 edit distance
随机推荐
爱可可AI前沿推介(7.6)
Redis insert data garbled solution
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
每个程序员必须掌握的常用英语词汇(建议收藏)
Interviewer: what is the internal implementation of ordered collection in redis?
Performance test process and plan
愛可可AI前沿推介(7.6)
正则表达式收集
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
R语言做文本挖掘 Part4文本分类
Variable star --- article module (1)
防火墙基础之外网服务器区部署和双机热备
SAP UI5 框架的 manifest.json
【滑动窗口】第九届蓝桥杯省赛B组:日志统计
Reinforcement learning - learning notes 5 | alphago
字符串的使用方法之startwith()-以XX开头、endsWith()-以XX结尾、trim()-删除两端空格
Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
全网最全的知识库管理工具综合评测和推荐:FlowUs、Baklib、简道云、ONES Wiki 、PingCode、Seed、MeBox、亿方云、智米云、搜阅云、天翎
KDD 2022 | 通过知识增强的提示学习实现统一的对话式推荐
Vim 基本配置和经常使用的命令