![d15c9402e43cf2788dc028599db0190a.png](https://img-blog.csdnimg.cn/img_convert/d15c9402e43cf2788dc028599db0190a.png)
习惯了IDE,vim编写需要一些插件才能更高效。
安装插件管理Vundle
- 克隆项目到本地
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
- 配置vimrc文件
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
如果想下载某个插件,需要将Plugin 'xxxx'置于call vundle#begin()
和call vundle#end()
之间,保存配置后在vim中执行 - 下载插件执行
:PluginInstall
- 删除插件执行
:PluginClean
高效的插件和设置
- 自动补全括号和引号等
Plugin 'jiangmiao/auto-pairs'
- molokai主题 网上下载”monokai.vim”并放在~/.vim下的colors文件夹下(没有的话新建一个colors文件夹); 下载链接:https://github.com/tomasr/molokai/blob/master/colors/molokai.vim 然后在~/.vimrc 文件中添加如下代码:
syntax enable
set background=dark
:colorscheme molokai
![ee10d71de76de59ea17e9969316d285c.png](https://img-blog.csdnimg.cn/img_convert/ee10d71de76de59ea17e9969316d285c.png)
3. 设置自动缩进、行号等:终端打开vim ~/.vimrc
添加
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set cindent
set cinoptions={
0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
set nu
set ruler
set hlsearch
set backspace=2
下面是我的vimrc的完整配置,可以直接粘贴复制
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'w0rp/ale'
Plugin 'scrooloose/nerdtree' " File tree manager
Plugin 'jiangmiao/auto-pairs'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set cursorline
set cindent
set cinoptions={
0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
set nu
set ruler
syntax enable
set background=dark
:colorscheme molokai
set hlsearch
set backspace=2
"-----------------------------------------------------------------------------
" plugin - ale.vim
"-----------------------------------------------------------------------------
"keep the sign gutter open
let g:ale_sign_column_always = 1
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
" show errors or warnings in my statusline
let g:airline#extensions#ale#enabled = 1
" self-define statusline
"function! LinterStatus() abort
" let l:counts = ale#statusline#Count(bufnr(''))
"
" let l:all_errors = l:counts.error + l:counts.style_error
" let l:all_non_errors = l:counts.total - l:all_errors
"
" return l:counts.total