我们可以利用现有的脚本来配置,或是自己编写配置文件,这里主要讲解利用git上的脚本配置本地的vim插件,实现常用功能。
1.cscope
The plug-in: scope 插件已经安装,cscope常用来快速跳转到相应的函数变量,但是在使用之前,需要建立某个文件下的所有依赖关系,然后应用才能跳转。
find ./ -name "*.h" -o -name "*.hpp" -o -name "*.hxx" -o -name "*.c" -o -name "*.C" -o -name "*.cpp" -o -name "*.cxx" -o -name "*.cc" -o -name "*.c++” > scope.files
cscope -bkq -i cscope.files
快捷键:ctrl + } 函数跳转 ctrl+t 回退
2.脚本插件
适合linux/macos/unix
2 . 1 在~/ 目录下运行,安装bundle, 其会自动创建后面的目录,和内容。
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
2.2添加 ~/.vimrc.bundles , 文件里面是需要安装的插件,可以添加和删除不需要的内容:
见3,可直接粘贴。
2.3 修改 ~/.vimrc ,配置中添加关联bundles的配置,前三行。也可以直接复制后面的内容即可。
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
2.4安装: 然后home目录下,直接vim,然后进入:模式,
然后BundleInstall/BundleUpdate 安装和更新即可, 它会自动到github拿下脚本执行。
3.配置文件内容
.vimrc
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
set backspace=indent,eol,start
filetype plugin on
syntax on
nmap <F5> :NERDTreeToggle<cr>
nmap <F9> :TagbarToggle<cr>
""colo happy_hacking
""colo gruvbox
colo minimalist
"colo angr
"previous seting"
"colorscheme desert
set background=dark
set tabstop=4 " The width of a TAB is set to 4.
" Still it is a \t. It is just that
" Vim will interpret it to be having
" a width of 4.
set shiftwidth=4 " Indents will have a width of 4
set softtabstop=4 " Sets the number of columns for a TAB
set expandtab " Expand TABs to spaces
set hlsearch
set colorcolumn=81 "highlight >80
" Add full file path to your existing statusline
set statusline=%<%F\ %h%m%r%y%=%-14.(%l,%c%V%)\ %P
set ls=2
.vimrc.bundles
if &compatible
set nocompatible
end
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Let Vundle manage Vundle
Bundle 'gmarik/vundle'
" Define bundles via Github repos
Bundle "scrooloose/nerdtree"
Bundle "ivalkeen/nerdtree-execute"
Bundle "scrooloose/nerdcommenter"
Bundle 'Valloric/YouCompleteMe'
Bundle 'scrooloose/syntastic'
" Bundle 'Lokaltog/vim-powerline'
Bundle 'kien/ctrlp.vim'
Bundle "rafi/awesome-vim-colorschemes"
Bundle 'danro/rename.vim'
Bundle 'majutsushi/tagbar'
Bundle 'pbrisbin/vim-mkdir'
Bundle 'luochen1990/rainbow'
Bundle 'AutoClose'
Bundle 'ShowTrailingWhitespace'
Bundle 'terryma/vim-multiple-cursors'
Bundle 'easymotion/vim-easymotion'
Bundle 'rking/ag.vim'
Bundle 'tpope/vim-fugitive'
Bundle 'vim-scripts/ctags.vim'
Bundle 'powerline/powerline'
Bundle 'vim-airline/vim-airline'
Bundle 'EasyGrep'
" Lightweight support for Ruby's Bundler
Bundle 'tpope/vim-bundler'
" Rspec, Behaviour Driven Development for Ruby
Bundle 'thoughtbot/vim-rspec'
" for javascript
Bundle 'kchmck/vim-coffee-script'
" for slim, fast, lightweight templating engine with support for Rails 3 and 4
Bundle 'slim-template/vim-slim'
if filereadable(expand("~/.vimrc.bundles.local"))
source ~/.vimrc.bundles.local
endif
filetype on
4.使用
Using Background-scheme: milimalist
vim一次修改 :colo angr
.vimrc :colo angr
https://github.com/rafi/awesome-vim-colorschemes
ctrl+p 模糊匹配搜索文件
Ctrl + v 搜索到后分屏打开另一个文件
Fn + F5 左侧目录
Fn + F9 右侧声明