" NERDTree config
" open a NERDTree automatically when vim starts up
autocmd vimenter * NERDTree
"open a NERDTree automatically when vim starts up if no files were specified
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
"open NERDTree automatically when vim starts up on opening a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
"map F2 to open NERDTree
map <F2> :NERDTreeToggle<CR>
"close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
复制代码
The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). YCM core library not detected; you need to compile YCM before using it. Follow the instructions in the documentation
复制代码
" Tagbar
let g:tagbar_width=35
let g:tagbar_autofocus=1
let g:tagbar_left = 1
nmap <F3> :TagbarToggle<CR>
复制代码
这样通过按F3就可以调出TagBar的窗格。
Ctrap
在一开始的图中,我的下窗格是专门用来搜索文件的,使用Ctrap这个插件可以支持搜索。 安装
Plugin 'ctrlpvim/ctrlp.vim'复制代码
执行完安装命令:PluginInstall后,我们做一些设置:
" 打开ctrlp搜索
let g:ctrlp_map = '<leader>ff'
let g:ctrlp_cmd = 'CtrlP'
" 相当于mru功能,show recently opened files
map <leader>fp :CtrlPMRU<CR>
"set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux"
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn|rvm)$',
\ 'file': '\v\.(exe|so|dll|zip|tar|tar.gz)$',
\ }
"\ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
let g:ctrlp_working_path_mode=0
let g:ctrlp_match_window_bottom=1
let g:ctrlp_max_height=15
let g:ctrlp_match_window_reversed=0
let g:ctrlp_mruf_max=500
let g:ctrlp_follow_symlinks=1
复制代码
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files.
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'" Ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
复制代码
vim-powerline
这个工具主要用来增强状态栏的,显示更多的信息,文件格式,当前状态,路径
Plugin 'Lokaltog/vim-powerline'let g:Powerline_symbols = 'fancy'set encoding=utf-8
set laststatus=2
复制代码
"==========================================
"General
"==========================================
"history存储长度。
sethistory=1000
"检测文件类型
filetype on
" 针对不同的文件类型采用不同的缩进格式
filetype indent on
允许插件
filetype plugin on
启动自动补全
filetype plugin indent on
"兼容vi模式。去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set nocompatible
set autoread " 文件修改之后自动载入。
set shortmess=atI " 启动的时候不显示那个援助索马里儿童的提示
" 取消备份。
"urn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
"贴时保持格式
set paste
"- 则点击光标不会换,用于复制
set mouse-=a " 在所有的模式下面打开鼠标。
set selection=exclusive
set selectmode=mouse,key
" No annoying sound on errors
" 去掉输入错误的提示声音
set noerrorbells
set novisualbell
set t_vb=
set tm=500
"==========================================
" show and format
"==========================================
"显示行号:
set number
set nowrap " 取消换行。
"为方便复制,用<F6>开启/关闭行号显示:
nnoremap <F6> :set nonumber!<CR>:set foldcolumn=0<CR>
"括号配对情况
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
"设置文内智能搜索提示
" 高亮search命中的文本。
set hlsearch
" 搜索时忽略大小写
set ignorecase
" 随着键入即时搜索
set incsearch
" 有一个或以上大写字母时仍大小写敏感
set smartcase
" 代码折叠
set foldenable
" 折叠方法
" manual 手工折叠
" indent 使用缩进表示折叠
" expr 使用表达式定义折叠
" syntax 使用语法定义折叠
" diff 对没有更改的文本进行折叠
" marker 使用标记进行折叠, 默认标记是 {{{ 和 }}}
set foldmethod=syntax
" 在左侧显示折叠的层次
"set foldcolumn=4
set tabstop=4 " 设置Tab键的宽度 [等同的空格个数]
set shiftwidth=4
set expandtab " 将Tab自动转化成空格 [需要输入真正的Tab键时,使用 Ctrl+V + Tab]
" 按退格键时可以一次删掉 4 个空格
set softtabstop=4
set ai "Auto indent
set si "Smart indent
"==========================================
" status
"==========================================
"显示当前的行号列号:
set ruler
"在状态栏显示正在输入的命令
set showcmd
" Set 7 lines to the cursor - when moving vertically using j/k 上下滚动,始终在中间
set so=7
"set cursorline " 突出显示当前行
复制代码
由于篇幅问题,再推荐其它一些好用的插件
" Improved C++ STL syntax highlighting
Plugin 'STL-improved'
" recommend fetch it from https://github.com/tczengming/autoload_cscope.vim.git which support c and cpp
Plugin 'tczengming/autoload_cscope.vim'
Plugin 'CmdlineComplete'
Plugin 'xptemplate'" Ultimate auto completion system for Vim
Plugin 'neocomplcache'
Plugin 'genutils'
Plugin 'lookupfile'
" Fast file navigation
Plugin 'wincent/Command-T'" Preview the definition of variables or functions in a preview window
Plugin 'autopreview'
" Echo the function declaration in the command line for C/C++
Plugin 'echofunc.vim'" Under linux need exec 'dos2unix ~/.vim/bundle/QFixToggle/plugin/qfixtoggle.vim'
Plugin 'Toggle'
Plugin 'Color-Sampler-Pack'
Plugin 'txt.vim'
Plugin 'mru.vim'
Plugin 'YankRing.vim'
Plugin 'tpope/vim-surround.git'
Plugin 'DoxygenToolkit.vim'
Plugin 'tczengming/headerGatesAdd.vim'
Plugin 'ShowMarks'
Plugin 'Lokaltog/vim-powerline'
复制代码