相关教程可参考:https://wizardforcel.gitbooks.io/use-vim-as-ide/content/0.html
安装Vundle
先参考 https://github.com/VundleVim/Vundle.vim 安装Vundle。大概步骤如下
- 安装curl
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
- 运行 vim 并运行
:PluginInstall
为安装YouCompleteMe,执行完Pligininstall后,还需如下步骤:
.vimrc
"--------------------------- required by vundle ---------------------------------
"https://github.com/VundleVim/Vundle.vim
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()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" plugin on GitHub repo
Plugin 'scrooloose/nerdtree'
Plugin 'fatih/vim-go'
Plugin 'Valloric/YouCompleteMe'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"---------------------------- my config ----------------------------------------
"定义快捷键的前缀键,即<Leader>
let mapleader=";"
"如果需要,之后可以使用 autocmd 为不同的文件类型应用不同的 tab 设置
"设定tab等同的空格长度
set tabstop=4
"程序自动缩进时所使用的空白长度
"以及设定<<和>>命令移动时的宽度
set shiftwidth=4
"将tab转为空格i
"如果文件里本来就有tab ,可以用 :retab 命令,将所有 tab 扩展成空格
set expandtab
set smarttab
"自动对齐,在用鼠标进行复制粘贴时要关掉这两个
"关闭命令 :set noai nosi
"最优方法是粘贴前使用 :set paste 进入粘贴模式,会自动帮我们处理
set autoindent
set smartindent
"鼠标可用
"set mouse=a
"高亮查找匹配
set hlsearch
"显示匹配
set showmatch
"显示标尺,就是右下角显示光标位置
set ruler
"语法高亮
syntax on
"显示行号
set nu
"关闭备份
set nobackup
"文件自动检测外部更改
set autoread
"---------------------------- for NERDTree ----------------------------------------
" 使用 NERDTree 插件查看工程文件。设置快捷键,速记:file list
nmap <Leader>fl :NERDTreeToggle<CR>
" 设置NERDTree子窗口宽度
let NERDTreeWinSize=32
" 设置NERDTree子窗口位置
let NERDTreeWinPos="right"
" 显示隐藏文件
let NERDTreeShowHidden=1
" NERDTree 子窗口中不显示冗余帮助信息
let NERDTreeMinimalUI=1
" 删除文件时自动删除文件对应 buffer
let NERDTreeAutoDeleteBuffer=1
augroup filetype
autocmd! BufRead,BufNewFile BUILD set filetype=blade
augroup end