Vim 基本设置

Vim基础配置

打开命令行,运行下列命令:

sudo vim ~/.vimrc

设置文件如下:

" 显示行号
set number

" 语法高亮
syntax on

" 高亮当前行
set cursorline

" 在状态栏显示当前模式
set showmode

" 显示输入的命令
set showcmd

" 启用鼠标支持
set mouse=a

" 自动缩进
set autoindent

" 智能缩进
set smartindent

" 制表符宽度
set tabstop=4
set shiftwidth=4

" 将Tab转换为空格
set expandtab

" 搜索时忽略大小写
set ignorecase
set smartcase

" 搜索时实时高亮
set incsearch
set hlsearch

" 代码折叠
set foldmethod=indent

" 编码设置
set encoding=utf-8
set fileencodings=utf-8,gbk

" 显示匹配的括号
set showmatch

" 设置命令行高度
set cmdheight=1

" 允许隐藏被修改的buffer
set hidden

" 启用真彩色
set termguicolors

Vim 相关链接

Vim 命令大全:从入门到精通

posted @ 2026-04-06 01:42  Zhuye_inking  阅读(7)  评论(0)    收藏  举报