当前位置:网站首页>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
边栏推荐
猜你喜欢
This year, Jianzhi Tencent
ICML 2022 | Flowformer: 任务通用的线性复杂度Transformer
3D人脸重建:从基础知识到识别/重建方法!
[MySQL] basic use of cursor
SAP UI5 框架的 manifest.json
LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
愛可可AI前沿推介(7.6)
Opencv learning example code 3.2.3 image binarization
Distributed ID
Why do job hopping take more than promotion?
随机推荐
The most comprehensive new database in the whole network, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, flying Book Multidimensional table, heipayun, Zhix
Select data Column subset in table R [duplicate] - select subset of columns in data table R [duplicate]
Ravendb starts -- document metadata
监控界的最强王者,没有之一!
R语言做文本挖掘 Part4文本分类
Regular expression collection
Pycharm remote execution
document.write()的用法-写入文本——修改样式、位置控制
#yyds干货盘点#重新梳理箭头函数的this
Manifest of SAP ui5 framework json
性能测试过程和计划
Distributed ID
What is the problem with the SQL group by statement
Statistical inference: maximum likelihood estimation, Bayesian estimation and variance deviation decomposition
Nodejs tutorial expressjs article quick start
【深度学习】PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
Spiral square PTA
如何实现常见框架
Swagger UI tutorial API document artifact
OAI 5g nr+usrp b210 installation and construction