1. vim two configuration methods
1) profile
global configuration files: / etc / vim / vimrc or / etc / vimrc
user personal profile: ~ / .vimrc
2) Command mode
input configuration commands directly to the command mode. As :set number
.
Discover a CI is open, you can enter the command in the command line, and followed by a question mark. Such as:set number?
2. Common configuration items
CI generally "open" and "closed" two settings, "close" is generally in the "open" them with the prefix "no". Such as:
set number //显示行号
set nonumber //关闭行号
2.1 Basic Configuration
syntax on //设置语法高亮
set showmode //在底部显示当前处于命令模式还是插入模式
set mouse=a //支持使用鼠标
set encoding=utf-8 //使用utf-8编码
filetype indent on //开启文件类型检查,并且载入与该类型对应的缩进规则。比如,如果编辑的是.py文件,vim就会找python的缩进规则~/.vim/indent/python.vim
2.2 retracted configuration
set autoindent //保持与上一行缩进一致
set tabstop=2 //tab字符显示为多少个空白字符的宽度
set shiftwidth=4 //自动缩进显示的空白字符的宽度
set expandtab //tab字符替换为空格
set softtabstop=2 //tab转换为多少个空白字符
2.3 Appearance
set number //显示行号
set relativenumber //显示光标所在的当前行的行号,其他行都为相对于该行的相对行号
set cursorline //光标所在的当前行高亮
set textwidth=80 //设置行宽,即一行显示多少个字符
set wrap //自动折行,即太长的行分成几行显示
set nowrap //关闭自动折行
set linebreak //遇到特定的字符(比如空格和其它标点字符)才发生折行。也就是说,不会在单词内部折行。
set wrapmargin=2 //指定折行处与编辑窗口的右边缘之间空出的字符数
set laststatus=2 //是否显示状态栏。0表示不显示,1表示只在多窗口时显示,2表示显示。
set ruler //在状态栏显示光标的当前位置