Skip to content

Instantly share code, notes, and snippets.

@fanzeyi
Created December 25, 2010 09:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fanzeyi/754789 to your computer and use it in GitHub Desktop.
Save fanzeyi/754789 to your computer and use it in GitHub Desktop.
vim配置文件
" VIM配置文件
" Author: Fanzeyi (fanzeyi1994[at]gmail.com)
" Last Modified Date: 2010-10-13 17:49
" 设置语言及编码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set enc=utf-8
" set fencs=utf-8,ucs-bom,gbk,gb18030,shift-jis,gb2312,cp936
" 常规设置
set nocompatible " 关闭vi兼容模式
set number " 打开行号
filetype plugin 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 softtabstop=4
set tabstop=8
"set smarttab
set nobackup " 关闭自动保存
set noswapfile " 关闭交换文件
set laststatus=2 " 设置命令缓冲区可见
set whichwrap+=<,>,h,l " 输入时光标会短暂位于相匹配的括号位置
set fdm=syntax " 设置语法折叠
set modeline " 設置Modeline
set go=i " 设置滚动条消失
" 函数
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
func! RunPython()
exec "w"
exec "!python %"
endfunc
func! CompileRunHaskell()
exec "w"
exec "!ghc % -o %<"
endfunc
func! AppendModeline() " 自動插入modeline
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d :",
\ &tabstop, &shiftwidth, &textwidth)
let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
call append(line("$"), l:modeline)
endfunc
" 键位绑定
" F5为自动编译运行
if &filetype == 'C'
map <F5> :call CompileRunGcc()<CR>
elseif &filetype == 'Python'
map <F5> :call RunPython()<CR>
elseif &filetype == 'haskell'
map <F5> :call CompileRunHaskell()<CR>
endif
" F6为自动调试
map <F6> :call GdbCode()<CR>
" 空格控制折叠
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" F3插入模板
map <F3> : LoadTemplate <CR>
" Ctrl+N 键下个错误
map <C-N> : cn <CR>
" Ctrl+P 键上个错误
map <C-P> : cp <CR>
" 自動插入 Modeline
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>
" 其他
set makeprg=gcc\ -g\ -lm\ -Wall\ -o\ %<\ % " 设置make命令
copen 5 " 自动打开QuickFix列表并设置高为5行
colo random " 设置配色方案为lucius
set guifont=Zpix\ C.O.D.E\ Medium\ 14 " 设置字体
" set guifont=Anonymous\ Pro\ 14
set linespace=2
set completeopt=longest,menu " 设置自动补全格式
autocmd FileType * setlocal et sta sw=4 sts=4
" 插件
" 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
" VimWiki
let g:vimwiki_use_mouse = 1
let g:vimwiki_list = [{ 'path': '~/.vimdiary/',
\ 'auto_export': 1},
\{'path': '~/.vimwiki/',
\ 'path_html': '~/.vimwiki/html/',
\ 'html_header': '~/.vimwiki/template/header.html',
\ 'html_footer': '~/.vimwiki/template/footer.html',
\ 'auto_export': 1}]
let g:vimwiki_valid_html_tags='b,i,s,u,sub,sup,kbd,del,br,hr,div,code,h1,script'
let g:vimwiki_hl_cb_checked = 1
let g:vimwiki_camel_case = 0
" sessionman_save_on_exit
" let g:sessionman_save_on_exit = 1
"let g:session_dir = '~/.vim/my-session'
" Calendar
map <F8> :Calendar<cr>
" 自动检测编码
""let g:fencview_autodetect = 1
""let g:fencview_checklines = 10
""autocmd BufReadPost * FencAutoDetect
" Fanvim
let fanvim_login="fanzeyi:******"
" PyLint
autocmd FileType python compiler pylint
" Python自动补全
let g:pydiction_location = '~/.vim/complete-dict'
" 其他编程语言补全
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