当前位置:网站首页>VIM installation and common commands
VIM installation and common commands
2022-06-12 15:23:00 【Stars_ min】
1. vim install
Online installation ( Suggest )
sudo apt-get install vim (ubuntu)
yum install vim (redHat/Fedora/CentOS)
2. vim Use
2.1 vim Working mode of : Command mode 、 Edit mode 、 Last row mode
It's directly in vim + file name , Editing
Common commands
| meaning | command |
|---|---|
| Add batch comments | 1. First, position the cursor to the front of the annotation 2.ctrl+v Enter view mode , Move the cursor down or up , Move to the last line of the comment 3. Then press the capital i(shift+i), Insert a comment , Annotators such as # wait 4. Finally according to the esc , This completes all the selected comments |
| Remove the batch comment | 1. ctrl+v Enter view mode , Select the area to uncomment 2. Then press d, The selected annotation symbol will be deleted |
| Cut text | 1. ctrl+v Enter view mode , Select the text to cut 2. Click on y replicate 3. Click on p To shear 4. Click on p replicate Cut the cursor position of the current line to the end of the line :d$ Cut the cursor position of the current line to the beginning of the line :d^ Cut three lines :3dd, From the current line + The next two lines are cut shear 1-10 To 20 That's ok ( In parentheses ):(:1,10 m 20) |
| Delete | 1. Delete a line : dd 2. Delete... Starting with the current line n That's ok : ndd 3. Delete a character starting with the current character : dw 4. Delete... Starting with the current character n Characters : ndw 5. Delete a line of characters starting with the current character : d$ , D 6. Delete to the beginning of the next sentence : d) 7. Delete to the beginning of the next paragraph : d} 8. Delete two lines : d + enter |
| Copy | Will be the first 9 Travel to 15 Row data , Copied to the 16 That's ok 1. (:9,15 copy 16 perhaps :9,15 co 16) 2.ctrl+v Enter view mode , Select the copied text , Click on y, Select the place to paste with the cursor ,esc Exit visual mode , Click on p replicate |
| Line break | Click on o You can change lines ( It's just edit mode , Pay attention to the ) |
| Recall operation | Click on u You can undo the last input ( This can only be used in normal mode ) |
| Add the line number before each line | :set su |
| Cancel the line Numbers | :set nonu |
| Turn on mouse control | :set mouse=a |
| Set the search highlight | :set hls |
| Set the font | :set guifont=monaco\10 |
| Mark the current line | :set sursorline |
| Exit in command mode and save | :wq |
| Exit without modification | :q |
| Forced exit , Do not save | :q! |
| The cursor jumps to the beginning of the specified line | : Line number |
| The cursor moves to the last line | G |
| The cursor moves to the first line | gg |
| Character replacement | 1. :%s/ Source characters / Replace character ( Replace the first source character appearing on each line with the target character ) 2. :%s/ Source characters / The replaced character /g( Replace the full-text source character with the target character )3. : 8,10s/ Source characters / Replace the character after /g( Replace the characters on lines 8 to 10 ) |
2. 2 Set some line numbers permanently , It can be done to /etc/vimrc Edit and add (vim /etc/vimrc), Become permanent , It is not necessary to set every time you enter the terminal ( Suggest : Add what you use , It's OK to add them all )
" Turn on syntax highlighting
syntax on
" Use color scheme
colorscheme desert
" Open the file type detection function
filetype on
" Different file types use different indents
filetype indent on
" Allow plug-ins
filetype plugin on
filetype plugin indent on
" close vi Pattern
set nocp
" And windows Share clipboard
set clipboard+=unnamed
" Cancel VI compatible ,VI Keyboard mode is not easy to use
set nocompatible
" According to the line Numbers , or set number
set nu
" History command save lines
set history=100
" Read automatically when the file is changed externally
set autoread
" Cancel automatic backup and generation swp file
set nobackup
set nowb
set noswapfile
" Allow mouse click to locate
set mouse=a
" Allow area selection
set selection=exclusive
set selectmode=mouse,key
" Highlight the line where the cursor is
set cursorline
" Cancel cursor blink
set novisualbell
" Always show status lines
set laststatus=2
" The status bar shows the currently executed command
set showcmd
" Scale function , Display the row number of the current cursor
set ruler
" Set the command line height to 3
set cmdheight=3
" Keep formatting when pasting
set paste
" Highlight the matching brackets
set showmatch
" Ignore case when searching
set ignorecase
" Highlight the sentence being searched
set hlsearch
" In search , Highlight the words and sentences one by one ( similar firefox Search for )
set incsearch
" Inherit the indent of the previous line , Especially for multiline comments
set autoindent
" by C The program provides automatic indentation
set smartindent
" Use C Indent of style
set cindent
" The box drawings are 4
set tabstop=4
" Indent uniformly to 4
set softtabstop=4
set shiftwidth=4
" Allow backspace key , or set backspace=2
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Cancel line break
set nowrap
" When it's launched, it doesn't show the hint of helping Somali children
set shortmess=atI
" Show white space between divided windows , Easy to read
set fillchars=vert:\ ,stl:\ ,stlnc:\
" Cursor moves to buffer Keep the top and bottom of 3 Row distance , or set so=3
set scrolloff=3
" Set the default decoding
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936
" set font
set guifont=Courier_New:h11:cANSI
set guifontwide= NSimSun :h11:cGB2312
" Set the code
set enc=utf-8
set fileencodings=ucs-bom,utf-8,chinese
set langmenu=zh_CN.UTF-8
language message zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" Automatic completion
filetype plugin indent on
set completeopt=longest,menu
" Use menu matching list when auto completion command
set wildmenu
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType java set omnifunc=javacomplete#Complet
边栏推荐
- Codeforces Round 797 (Div. 3,CF1690)全题解
- Dart typedef的理解
- Xshell 7 official website free download
- C escape character
- New关键字、引用&与指针的学习记录
- Using the CSDN markdown editor
- C string
- [LDA] rough version notes of EM variational reasoning [to be improved
- Village to village communication (and collective search)
- 学习是一件逆人性的事情(成为高手的内功心法)
猜你喜欢

Qiming Zhixian shares the application scheme of 2.8-inch handheld central control screen

RARP总结(TCP/IP详解卷1/2)

Microservice fault tolerance

Deepin20.6 rtx3080 installing graphics card drivers 510.60.02, cuda11.6, pytorch1.11

org. xml. sax. SAXParseException; lineNumber: 63; columnNumber: 10; The definition of "mapper" in the related type must be matched with "(CAC

3D reconstruction system | L3 incremental motion recovery structure (incremental SFM)
![[jvm learning] class loading subsystem](/img/60/e863495ce4ea5826d1404a73c90033.jpg)
[jvm learning] class loading subsystem

xshell 7 官网免费下载

Ngork implements intranet penetration -- free

解决log4j2漏洞遭到挖矿、僵尸进程病毒攻击
随机推荐
SOA Architecture
xshell 7 官网免费下载
如何写年终总结
学习是一件逆人性的事情(成为高手的内功心法)
解决log4j2漏洞遭到挖矿、僵尸进程病毒攻击
RARP summary (tcp/ip explanation volume 1/2)
Jupyter notebook new environment shortcut
Deepin20.6 RTX3080 安裝顯卡驅動510.60.02、CUDA11.6、PyTorch1.11
Deepin20.6 rtx3080 installing graphics card drivers 510.60.02, cuda11.6, pytorch1.11
Self induction of exception handling
分布式并发重复提交问题
Conversion between sparse array and array and file reading and writing
ngork实现内网穿透--免费
Dart typedef的理解
Deepin20.6 RTX3080 安装显卡驱动510.60.02、CUDA11.6、PyTorch1.11
Use and understanding of generics
[jvm learning] virtual machine stack
C scanf function
TF learning notes in ROS
The process of generating strong association rules from frequent itemsets