当前位置:网站首页>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,cp936vim 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
边栏推荐
- Pycharm remote execution
- 请问sql group by 语句问题
- 967- letter combination of telephone number
- 全网最全的知识库管理工具综合评测和推荐:FlowUs、Baklib、简道云、ONES Wiki 、PingCode、Seed、MeBox、亿方云、智米云、搜阅云、天翎
- JS operation DOM element (I) -- six ways to obtain DOM nodes
- El table table - sortable sorting & disordered sorting when decimal and% appear
- Regular expression collection
- Common English vocabulary that every programmer must master (recommended Collection)
- [redis design and implementation] part I: summary of redis data structure and objects
- OAI 5g nr+usrp b210 installation and construction
猜你喜欢

Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software

SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍

The difference between break and continue in the for loop -- break completely end the loop & continue terminate this loop

HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother

Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)

Redis insert data garbled solution

None of the strongest kings in the monitoring industry!

15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient

15 millions d'employés sont faciles à gérer et la base de données native du cloud gaussdb rend le Bureau des RH plus efficace

嵌入式开发的7大原罪
随机推荐
Aiko ai Frontier promotion (7.6)
面试官:Redis中有序集合的内部实现方式是什么?
Reinforcement learning - learning notes 5 | alphago
JS traversal array and string
OSPF多区域配置
请问sql group by 语句问题
JS operation DOM element (I) -- six ways to obtain DOM nodes
MLP (multilayer perceptron neural network) is a multilayer fully connected neural network model.
ICML 2022 | Flowformer: 任务通用的线性复杂度Transformer
Aike AI frontier promotion (7.6)
Taylor series fast Fourier transform (FFT)
Yyds dry goods count re comb this of arrow function
R語言可視化兩個以上的分類(類別)變量之間的關系、使用vcd包中的Mosaic函數創建馬賽克圖( Mosaic plots)、分別可視化兩個、三個、四個分類變量的關系的馬賽克圖
ICML 2022 | flowformer: task generic linear complexity transformer
【滑动窗口】第九届蓝桥杯省赛B组:日志统计
js 根据汉字首字母排序(省份排序) 或 根据英文首字母排序——za排序 & az排序
OSPF multi zone configuration
The use method of string is startwith () - start with XX, endswith () - end with XX, trim () - delete spaces at both ends
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
Seven original sins of embedded development