"Set mapleader
let mapleader = ","
let g:mapleader = ","
"显示行号
set nu
"打开语法高亮
syntax on
"打开搜索单词高亮显示
set hlsearch
"set nohlsearch
set softtabstop=4
set shiftwidth=4
"关闭自动备份
set nobackup
"自动缩进设置
set cindent
set smartindent
set incsearch
set autoindent
"Show matching bracets
set showmatch
"Get out of VI's compatible mode
set nocompatible
"Have the mouse enabled all the time
set mouse=a
"Set to auto read when a file is changed from the outside
set autoread
"Enable filetype plugin
filetype plugin on
filetype indent on
"设置配色方案为torte
colo torte
"设置支持的文件编码类项,目前设置为utf-8和gbk两种类型
set fileencodings=utf-8,chinese
"设置搜索结果高亮显示
"set hlsearch
"设置记录的历史操作列表
set history=50
"设置折叠
"set foldcolumn=2
"set foldmethod=indent
"set foldlevel=3
"AutoCommand
"新建.c,.h,.sh,.java文件,自动插入文件头
autocmd BufNewFile *.[ch],*.sh,*.java exec ":call SetTitle()"
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
"设置Java代码的自动补全
au FileType java setlocal omnifunc=javacomplete#Complete
"绑定自动补全的快捷键到;
imap ;
"设定开关Taglist插件的快捷键为F4,可以在VIM的左侧栏列出函数列表等
"map :Tlist
"设置程序的运行和调试的快捷键F5和Ctrl-F5
map :call CompileRun()
map :call Debug()
"设置tab操作的快捷键,绑定:tabnew到t,绑定:tabn, :tabp到n,
"p
map t :tabnew
map n :tabn
map p :tabp
"用cscope支持
set csprg=/usr/bin/cscope
let Tlist_Ctags_Cmd='/usr/bin/ctags'
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=1
"默认打开Taglist
"let Tlist_Auto_Open=1
"使用e打开当前文件同目录中的文件
if has("unix")
map ,e :e =expand("%:p:h") . "/"
else
map ,e :e =expand("%:p:h") . "\"
endif
"定义CompileRun函数,用来调用进行编译和运行
func CompileRun()
exec "w"
"C程序
if &filetype == 'c'
exec "!gcc % -g -o %<"
exec "!./%<"
"Java程序
elseif &filetype == 'java'
exec "!javac %"
exec "!java %<"
endif
endfunc
"结束定义CompileRun
"定义Debug函数,用来调试程序
func Debug()
exec "w"
"C程序
if &filetype == 'c'
exec "!gcc % -g -o %<"
exec "!gdb %<"
"Java程序
elseif &filetype == 'java'
exec "!javac %"
exec "!jdb %<"
endif
endfunc
"结束定义Debug
"定义函数SetTitle,自动插入文件头
func SetTitle()
"如果文件类型为.sh文件
if &filetype == 'sh'
call setline(1, "\#########################################################################")
call append(line("."), "\# Author: Charlse.Zhang")
call append(line(".")+1, "\# Created Time: ".strftime("%c"))
call append(line(".")+2, "\# File Name: ".expand("%"))
call append(line(".")+3, "\# Description: ")
call append(line(".")+4, "\#########################################################################")
call append(line(".")+5, "\#!/bin/bash")
call append(line(".")+6, "")
else
call setline(1, "/*************************************************************************")
call append(line("."), " Author: Charlse.Zhang")
call append(line(".")+1, " Created Time: ".strftime("%c"))
call append(line(".")+2, " File Name: ".expand("%"))
call append(line(".")+3, " Description: ")
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
endif
endfunc
阅读(1329) | 评论(0) | 转发(0) |