set modifiable
"vundle config
set nocompatible "与vi不一致
filetype off
set rtp+=~/.vim/bundle/vundle/ "载入特定目录插件
call vundle#rc()
" let Vundle manage Vundle
Bundle 'gmarik/vundle'
"my bundles
"非github上资源
"Bundle 'git://git.wincent.com/command-t.git'
"github
Bundle 'altercation/solarized.git'
Bundle 'taglist.vim'
Bundle 'ervandew/supertab'
Bundle 'kien/ctrlp.vim'
Bundle 'DoxygenToolkit.vim'
Bundle 'genutils'
Bundle 'lookupfile'
Bundle 'OmniCppComplete'
"这个命令打开语法高亮
syntax enable
syntax on " 语法高亮
"在状态行上显示光标所在位置的行号和列号
set ruler
"高量显示匹配的括号
set showmatch
set list
set lcs=tab:\ \ ,trail:░
"tab实际占有的列数
set tabstop=4
"自动缩进所使用的空白长度
set shiftwidth=4
"将tab转成空格
set expandtab
set softtabstop=4
set smarttab
"显示行号
set nu
"high light current line
set cursorline
set colorcolumn=80
"search highlight
set hlsearch
"忽略大小写
set ignorecase
set fileencodings=utf-8,gbk,ucs-bom,cp936
"允许使用鼠标
set mouse=v
"vim工作在不兼容模式
set nocp
"显示当前文件名
"set statusline+=%f
set laststatus=2 "总是显示状态栏
highlight StatusLine cterm=bold ctermfg=yellow ctermbg=blue
" 获取当前路径,将$HOME转化为~
function! CurDir()
let curdir = substitute(getcwd(), $HOME, "~", "g")
return curdir
endfunction
"set statusline=[%n]\ %f%m%r%h\ \ %{CurDir()}\ %c
set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] "显示文件名:总行数,总的字符数
set ruler "在编辑过程中,在右下角显示光标位置的状态行
"依文件类型设置自动缩进
filetype indent on
filetype plugin on
"omni completion
set ofu=syntaxcomplete#Complete
imap <silent> ` <C-X><C-O>
"配色方案
set t_Co=256 " explicitly tell vim that the erminal supports 256 colors
let g:solarized_termcolors=256
set background=dark
colorscheme solarized
"ctags
set autochdir
"set tags=tags
set tags=./tags,tags;
""taglist config
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Left_Window=1
"cscope config
function! LoadCscope()
let db = findfile("cscope.out", ".;")
if (!empty(db))
let path = strpart(db, 0, match(db, "/cscope.out$"))
set nocsverb "suppress 'duplicate connection' error
exe "cs add " . db . " " . path
set csverb
endif
endfunction
au BufEnter /* call LoadCscope()
"function LoadCscope(path)
" "防止无限递归
" if a:path == $HOME
" return
" endif
" if (executable("cscope") && has("cscope"))
" let l:outfile=a:path."/cscope.out"
" let l:outpath=a:path
" if filereadable(outfile)
" cs reset
" exe "cs add" outfile outpath
" else
" "递归
" let l:newpath=a:path."/.."
" let newpath=resolve(newpath)
" "echo newpath
" call LoadCscope(newpath)
" endif
" endif
"endfunction
"call LoadCscope(getcwd())
set cscopequickfix=s-,c-,d-,i-,t-,e-
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
"快捷窗口
nmap <F4> :cn<cr>
nmap <F3> :cp<cr>
nmap <c-t> :colder<CR>:cc<CR>
"Supertab config
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="context"
"let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
"NERDTree config
"nmap <F3> :NERDTree <CR>
"win manage
"nmap wm :WMToggle <CR>
"let g:winManagerWindowLayout="TagList"
"
"function! NERDTree_Start()
" exec 'NERDTree'
"endfunction
"
"function! NERDTree_IsValid()
" return 1
"endfunction
let g:DoxygenToolkit_briefTag_pre="@Synopsis "
let g:DoxygenToolkit_paramTag_pre="@Param "
let g:DoxygenToolkit_returnTag="@Returns "
let g:DoxygenToolkit_blockHeader="/*************************************************"
let g:DoxygenToolkit_blockFooter="*************************************************/"
let g:DoxygenToolkit_licenseTag=""
"vim licenses
command! License call InsertLicense('ac')
let g:licenses_default_commands = ['ac']
nmap <F9> :License<cr>
map <C-K> :py3f /home/jeffrey/workspace/tools/clang-format.py<cr>
imap <C-K><c-o>:py3f /home/jeffrey/workspace/tools/clang-format.py<cr>
.clang-format
BasedOnStyle: LLVM
#指针的*的挨着哪边
PointerAlignment: Right
#缩进宽度
IndentWidth: 4
# 连续的空行保留几行
MaxEmptyLinesToKeep: 1
# 在 @property 后面添加空格, \@property (readonly) 而不是 \@property(readonly).
ObjCSpaceAfterProperty: true
# OC block后面的缩进
ObjCBlockIndentWidth: 4
# 是否允许短方法单行
AllowShortFunctionsOnASingleLine: false
# 是否允许短if单行 If true, if (a) return; 可以放到同一行
AllowShortIfStatementsOnASingleLine: false
# 允许短的循环保持在同一行
AllowShortLoopsOnASingleLine: false
# 每行字符的限制,0表示没有限制
ColumnLimit: 80
#注释对齐
AlignTrailingComments: true
# 换行的时候对齐操作符
AlignOperands: true
# 缩进case标签
IndentCaseLabels: true
# 中括号两边空格 []
SpacesInSquareBrackets: true
# 小括号两边添加空格
SpacesInParentheses : false
#多行声明语句按照=对齐
AlignConsecutiveDeclarations: true
#连续的赋值语句以 = 为中心对齐
AlignConsecutiveAssignments: true
#等号两边的空格
SpaceBeforeAssignmentOperators: true
# 容器类的空格 例如 OC的字典
SpacesInContainerLiterals: true
#缩进
IndentWrappedFunctionNames: true
#在block从空行开始
KeepEmptyLinesAtTheStartOfBlocks: true
#在构造函数初始化时按逗号断行,并以冒号对齐
BreakConstructorInitializersBeforeComma: true
#函数参数换行
AllowAllParametersOfDeclarationOnNextLine: true
#括号后添加空格
SpaceAfterCStyleCast: true
#tab键盘的宽度
TabWidth: 4
UseTab: Never
/
安装bundle
git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
在命令模式下输入
:BundleList //会显示你vimrc里面填写的所有插件名称
:BundleInstall //会自动下载安装或更新你的插件
卸载插件
如果要卸载插件就只需要删除.vimrc中的Bundle,然后在Vim中执行
[python] view plaincopy
- :BundleClean
如果使用的vundle安装的solorized,需要将.vim文件复制或者移动到~/.vim/colors/solarized.vim
SuperTab使Tab快捷键具有更快捷的上下文提示功能。
『下载和安装』
从http://www.vim.org/scripts/script.php?script_id=1643下载安装版。这个安装包跟先前的几个Vim插件不同,它是一个vba文件,即Vimball格式的安装包,这种格式安装包提供傻瓜式的安装插件的方法。
1)用Vim打开.vba安装包文件。
2)在Vim命令行下运行命令“UseVimball ~/.vim”。此命令将安装包解压缩到~/.vim目录。VImball安装方式的便利之处在于你可以在任何目录打开.vba包安装,而不用切换到安装目的地目录。而且不用运行helptags命令安装帮助文档。
3)在~/.vimrc文件中加入以下这行:
[html] view plaincopyprint?
- let g:SuperTabDefaultCompletionType="context"
『基本功能使用方法』
SuperTab使用很简单,只要在输入变量名或路径名等符号中途按Tab键,就能得到以前输入过的符号列表,并通过Tab键循环选择。
#!/bin/bash
DIR=`pwd`
if [ "$*" != "" ];
then
DIR=$*
fi
DIR=$(realpath $DIR)
echo $DIR
find -P $DIR -path -a -prune -o -name "*.h" -o -name "*.c" -o -name "*.cpp" -o -name "*.[sS]" -o -name "*.mk" -o -name "[mM]akefile" -o -name "*.ld" > cscope.files
cscope -Rbqk -i cscope.files
ctags -R $DIR