colo desert
set guifont=FreeMono\ 16
"不要使用vi的键盘模式,而是vim自己的
set nocompatible
" 语法高亮
set syntax=on
"依文件类型设置自动缩进
filetype indent plugin on
"显示当前的行号列号:
set ruler
"在状态栏显示正在输入的命令
set showcmd
"关闭/打开配对括号高亮
"NoMatchParen
set noeb
" 在处理存或只读文件的时候,弹出确认
set confirm
" 自动缩进
set autoindent
set cindent
" Tab键的宽度
set tabstop=4
" 统一缩进为4
set softtabstop=4
set shiftwidth=4
" 不要用空格代替制表符
set noexpandtab
" 在行和段开始处使用制表符
set smarttab
" 显示行号
set number
" ======= 编译 && 运行 ======= "
" 编译源文件
func! CompileCode()
exec "w"
if &filetype == "c"
exec "!gcc -Wall -std=c99 %<.c -o %<"
elseif &filetype == "java"
exec "!javac %<.java"
elseif &filetype == "python"
exec "!python %<.py"
elseif &filetype == "sh"
exec "!bash %<.sh"
elseif &filetype == "make"
exec "!make"
endif
endfunc
" 运行可执行文件
func! RunCode()
exec "w"
if &filetype == "c"
exec "! ./%<"
elseif &filetype == "java"
exec "!java %<"
elseif &filetype == "python"
exec "!python %<.py"
elseif &filetype == "sh"
exec "!bash %<.sh"
elseif &filetype == "make"
exec "! ./app"
endif
endfunc
" Ctrl + C 一键保存、编译
map <c-c> :call CompileCode()<CR>
imap <c-c> <ESC>:call CompileCode()<CR>
vmap <c-c> <ESC>:call CompileCode()<CR>
" Ctrl + R 一键保存、运行
map <c-r> :call RunCode()<CR>
imap <c-r> <ESC>:call RunCode()<CR>
vmap <c-r> <ESC>:call RunCode()<CR>