Skip to content

Instantly share code, notes, and snippets.

@lnsoso
Created November 14, 2010 11:26
Show Gist options
  • Save lnsoso/676092 to your computer and use it in GitHub Desktop.
Save lnsoso/676092 to your computer and use it in GitHub Desktop.
" VIM配置文件
" Author: Fanzeyi (fanzeyi1994[at]gmail.com)
" Last Modified Date: 2010-10-13 17:49
" 设置语言及编码
set langmenu=zh_CN
let $LANG = 'zh_CN'
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set enc=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set langmenu=zh_CN.UTF-8
set helplang=cn
" 常规设置
set nocompatible " 关闭vi兼容模式
set number " 打开行号
filetype on " 检测文件类型
set history=1000 " 设置最多记忆命令行数1000行
syntax on " 打开语法高亮
set autoindent " 打开自动缩进
set smartindent " 打开智能缩进
set showmatch " 设置括号匹配
set guioptions-=T " 去掉Toolbar
set vb t_vb= " 去掉声音提示
set ruler " 右下角显示光标状态行
set nohls " 关闭匹配的高亮显示
set incsearch " 设置快速搜索
set backspace=indent,eol,start " 设置<BS>键模式
set noexpandtab " 强制使用硬TAB
set nobackup " 关闭自动保存
set noswapfile " 关闭交换文件
set laststatus=2 " 设置命令缓冲区可见
set whichwrap+=<,>,h,l " 输入时光标会短暂位于相匹配的括号位置
set fdm=syntax " 设置语法折叠
" 函数
func Maximize_Window() " 自动最大化窗口
silent !wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
endfunc
func! CompileRunGcc() " 自动编译运行程序 (gcc)
exec "w"
exec "make"
exec "!./%<"
endfunc
func! GdbCode() " 自动编译调试 (gdb)
exec "w"
exec "!gcc -Wall -lm -g % -o %<"
exec "!gdb ./%<"
endfunc
" 键位绑定
" F5为自动编译运行
map <F5> :call CompileRunGcc()<CR>
" F6为自动调试
map <F6> :call GdbCode()<CR>
" 空格控制折叠
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" F3插入模板
map <F3> : LoadTemplate <CR>
" 其他
set makeprg=gcc\ -Wall\ -o\ %<\ % " 设置make命令
copen 5 " 自动打开QuickFix列表并设置高为5行
colo lucius " 设置配色方案为lucius
set guifont=FreeMono\ Bold\ 13 " 设置字体
set completeopt=longest,menu " 设置自动补全格式
" 插件
" Taglist
let Tlist_Use_LEFT_Window=1
let Tlist_File_Fold_Auto_Close=1
let Tlist_Show_One_File=1
let Tlist_GainFocus_On_ToggleOpen=0
let Tlist_Exit_OnlyWindow=1
let Tlist_Auto_Open=1
let Tlist_WinWidth=20
" 模板插件
let g:template_path = '~/.vim/template/'
" ACP插件
let g:acp_enableAtStartup = 1
" 其他编程语言补全
filetype plugin indent on
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType java set omnifunc=javacomplete#Complete
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment