前言
配置舒服的 vim 对于开发、学习相当重要
正文
安装 vim
sudo apt install vim
编辑vim配置文件
sudo gedit /etc/vim/vimrc
在文件末尾添加,不需要的可以用在句首加 井号(#)注释掉
set nu " 在左侧行号
set nobackup " 覆盖文件时不备份
set cursorline " 突出显示当前行
set ruler " 在右下角显示光标位置的状态行
set mouse=a " 启用鼠标支持
set laststatus=2 " 启用状态栏
set nocompatible " 不兼容 Vi 的设置
set backspace=indent,eol,start " 允许使用退格键删除光标前的字符
set encoding=utf-8 " 设置默认编码为 UTF-8
set fileencodings=utf-8,gbk,gb2312,gb18030 " 设置文件编码优先级
set fileformat=unix " 设置文件格式为 Unix
set fileformats=unix,dos,mac " 文件格式优先级
set fileencoding=utf-8 " 默认打开文件的编码为 UTF-8
set termencoding=utf-8 " 终端编码为 UTF-8
set tabstop=4 " 设置制表符宽度为 4
set shiftwidth=4 " 设置缩进宽度为 4
set hlsearch " 高亮搜索结果
set incsearch " 实时匹配搜索结果
set ignorecase " 忽略搜索时的大小写
set smartcase " 智能匹配搜索结果(大小写敏感)
syntax on " 启用语法高亮
#set expandtab " 将制表符转换为空格,要用 vim 写 makefile 文件不要加
#set ai " 自动缩进
#set autoindent " 自动缩进
#set si " 智能缩进
#set wrap " 自动换行