The process of upgrading vim and configuring vim yourself under Mac

1. Upgrade vim

My own MacBook Pro system is still 10.11, and its own vim version is 7.3, we will upgrade it to the latest version:

Using homebrew:

brew install vim --with-lua --with-override-system-vim
This will download the latest vim version and replace the vim that comes with the system.

After the installation is complete, restart the terminal, update the environment variables, and enter vim, and the version of vim will be the latest version.

If you want to update the vim version in the future, just enter brew upgrade vim to upgrade quickly.

If you want to add python3 support, add --with-python3 to the above command.

2. Configure your own .vimrc file

The vim configuration file is in the .vimrc file in the root directory, if not, create one yourself.

Open the .vimrc file and enter the configuration. My configuration is as follows:

复制代码
"显示行号
set nu

"启动时隐去援助提示
set shortmess=atI

"语法高亮
syntax on

"使用vim的键盘模式
set nocompatible

"不需要备份
set nobackup

"没有保存或文件只读时弹出确认
set confirm

"鼠标可用
set mouse-=a

"tab缩进
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab

"文件自动检测外部更改
set autoread

"c文件自动缩进
set cindent

"自动对齐
set autoindent

"智能缩进
set smartindent

"高亮查找匹配
set hlsearch

"显示匹配
set showmatch

"显示标尺,就是在右下角显示光标位置
set ruler

"去除vi的一致性
set nocompatible

"设置键盘映射,通过空格设置折叠
nnoremap <space> @=((foldclosed(line('.')<0)?'zc':'zo'))<CR>
""""""""""""""""""""""""""""""""""""""""""""""
"不要闪烁
set novisualbell

"启动显示状态行
set laststatus=2

"浅色显示当前行
autocmd InsertLeave * se nocul

"用浅色高亮当前行
autocmd InsertEnter * se cul

"显示输入的命令
set showcmd

"被分割窗口之间显示空白
set fillchars=vert:/
set fillchars=stl:/
set fillchars=stlnc:/

" vundle 环境设置
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
" vundle 管理的插件列表必须位于 vundle#begin() 和 vundle#end() 之间
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'tomasr/molokai'
Plugin 'vim-scripts/phd'
Plugin 'Lokaltog/vim-powerline'
Plugin 'octol/vim-cpp-enhanced-highlight'
Plugin 'Raimondi/delimitMate'
" 插件列表结束
call vundle#end()
filetype plugin indent on

" 配色方案
"set background=dark
"colorscheme solarized
"colorscheme molokai
"colorscheme phd

" 禁止显示菜单和工具条
set guioptions-=m
set guioptions-=T

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

" 禁止折行
set nowrap

" 设置状态栏主题风格
let g:Powerline_colorscheme='solarized256'

syntax keyword cppSTLtype initializer_list

" 基于缩进或语法进行代码折叠
"set foldmethod=indent
set foldmethod=syntax
" 启动 vim 时关闭折叠代码
set nofoldenable

"允许用退格键删除字符
set backspace=indent,eol,start

"编码设置
set encoding=utf-8

"共享剪切板
set clipboard=unnamed

Vim plugins are managed using vundle:

Install vundle:

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
As shown in my configuration file, Plugin 'plugin address' is to add plugins, such as:

Plugin 'dyng/ctrlsf.vim'
installs the plugin, first finds its address in github.com, then adds the configuration information between call vundle#begin() and call vundle#end() in .vimrc, and finally enters vim implement:

:PluginInstall
will complete the installation of the plugin.

To delete a plugin, just delete or comment out the Plugin 'plugin address', and then enter vim to execute:

:PluginClean
will delete the plugin.

To upgrade the plugin, enter vim and execute:

:PluginUpdate
to complete the upgrade.

Guess you like

Origin blog.csdn.net/qq_45206551/article/details/114641932