vim configuration and commands | Ubuntu+Vim

For software configuration, in principle, you don't need to worry about it after the first configuration, you don't need to learn, just select the required function configuration, and you will have your own accustomed configuration method over time. In order to avoid the trouble of configuring from scratch in the future, it is backed up.

My Vim configuration

" 不与vi兼容 高亮 uft8 256色
set nocompatible
syntax on
set encoding=utf-8  
set t_Co=256

" 自动对齐 tab转四个空格
set autoindent
set tabstop=4
set expandtab
set softtabstop=4

" --------------------------------------------------
" 以下部分可选 可通过命令临时设置
” 显示行号
set number
" 不显示行号
set nonumber
" 高亮当前行
set cursorline

" 行宽80 自动换行(不拆单词)
set textwidth=80
set wrap
set linebreak

" 括号配对高亮 搜索结果高亮
set showmatch
set hlsearch

filetype indent on		" 文件类型检查
set incsearch			" 搜索时自动跳转至第一个结果
set ignorecase			" 搜索忽略大小写
set spell spelllang=en_us		" 单词拼写检查

vim configuration and instructions

Reference link: Ruan Yifeng's web log: Introduction to Vim Configuration
Instructions : The original text is not convenient to copy, so I sorted it out. The comment is added in front for "easy copying.

basic configuration

Configuration file location: /etc/vim/vimrc

" 不与vi命令兼容
set nocompatible

" 打开语法高亮
syntax on

" 在底部显示当前处于命令模式还是插入模式
set showmode

" 命令模式下 在底部显示当前键入的指令
set showcmd

" 支持使用鼠标
set mouse=a

" 使用 utf-8 编码
set encoding=utf-8  

" 启用256色
set t_Co=256

" 开启文件类型检查 并且载入与该类型对应的缩进规则
filetype indent on

indentation

" 按下回车键后 下一行的缩进会自动跟上一行的缩进保持一致
set autoindent

" 按下 Tab 键时 Vim 显示的空格数
set tabstop=2

" 在文本上按下>>(增加一级缩进) <<(取消一级缩进) 或者 ==(取消全部缩进)时 每一级的字符数
set shiftwidth=4

" 由于 Tab 键在不同的编辑器缩进不一致 该设置自动将 Tab 转为空格
set expandtab

" Tab 转为多少个空格
set softtabstop=2

Exterior

" 显示行号
set number

" 显示光标所在的当前行的行号 其他行都为相对于该行的相对行号
set relativenumber

" 光标所在的当前行高亮
set cursorline

" 设置行宽 即一行显示多少个字符
set textwidth=80

" 自动折行 即太长的行分成几行显示
set wrap
" 关闭自动折行
set nowrap
" 只有遇到指定的符号(比如空格、连词号和其他标点符号)才发生折行 
" 也就是说 不会在单词内部折行
set linebreak

" 指定折行处与编辑窗口的右边缘之间空出的字符数
set wrapmargin=2

search for

" 光标遇到圆括号、方括号、大括号时 自动高亮对应的另一个圆括号、方括号和大括号
set showmatch

" 搜索时 高亮显示匹配结果
set hlsearch

" 输入搜索模式时 每输入一个字符就自动跳到第一个匹配的结果
set incsearch

" 搜索时忽略大小写
set ignorecase

" 如果同时打开了ignorecase 那么对于只有一个大写字母的搜索词 将大小写敏感
" 其他情况都是大小写不敏感
" 比如 搜索Test时 将不匹配test  搜索test时 将匹配Test

edit

" 打开英语单词的拼写检查
set spell spelllang=en_us

" 不创建备份文件
" 默认情况下 文件保存时会额外创建一个备份文件 它的文件名是在原文件名的末尾 再添加一个波浪号 ~
set nobackup

" 不创建交换文件
set noswapfile

" Vim 需要记住多少次历史操作
set history=1000

" 打开文件监视
" 如果在编辑过程中文件发生外部改变(比如被别的编辑器编辑了),就会发出提示
set autoread

" 如果行尾有多余的空格(包括 Tab 键)该配置将让这些空格显示成可见的小方块
set listchars=tab:»■,trail:■
set list

" 命令模式下 底部操作指令按下 Tab 键自动补全
" 第一次按下Tab 会显示所有匹配的操作指令的清单
" 第二次按下Tab 会依次选择各个指令
set wildmenu
set wildmode=longest:list,full

Guess you like

Origin blog.csdn.net/qq_40759015/article/details/114368425