vim 优化

  • 1330 字
  1. 1. 安装
  2. 2. 安装vim插件 tokyonight.vim(适配 Vim)
  3. 3. vim-plug插件管理
  4. 4. vim配置
  5. 5. 安装插件

安装

## 升级
brew install vim

安装vim插件 tokyonight.vim(适配 Vim)


mkdir -p ~/.vim/pack/themes/start

cd ~/.vim/pack/themes/start

git clone https://github.com/ghifarit53/tokyonight-vim.git

vim-plug插件管理

curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

vim配置


" ========== 外观配置 ==========

set termguicolors " 启用真彩色(需终端支持)

colorscheme tokyonight " 需预先安装 tokyonight-vim

syntax on " 启用语法高亮

highlight Comment ctermfg=6 " 改变注释颜色(终端模式下)

" ========== 基础 UI ==========

set number " 显示行号

set mouse=a " 启用鼠标支持

set clipboard=unnamedplus " 使用系统剪贴板(macOS 需 +clipboard 支持)

set laststatus=2 " 总是显示状态栏

set ruler " 显示光标位置

set cursorline " 高亮当前行

autocmd InsertLeave * set nocursorline

" ========== 搜索 ==========

set hlsearch " 高亮搜索结果

set incsearch " 输入时实时高亮

set ignorecase " 搜索忽略大小写

set showmatch " 匹配括号高亮

" ========== 缩进规则 ==========

set tabstop=4 " Tab 宽度

set shiftwidth=4 " 自动缩进宽度

set softtabstop=4 " 退格删除空格

set smarttab " 根据上下文智能缩进

set expandtab " ✅ 建议启用:tab → 空格,更兼容代码规范

" ========== 退格兼容 ==========

set backspace=indent,eol,start " 支持多种场景退格

  
" ========== 提示音控制 ==========

set noerrorbells

set novisualbell

安装插件

:PlugInstall