胡乱配了下vim

Author Avatar
Aryb1n 11月 25, 2016
syntax on
set cindent autoindent number sts=4 sw=4 ts=4 et
set backspace=indent,eol,start

autocmd FileType python setlocal makeprg=python\ %
autocmd FileType c setlocal makeprg=gcc\ -o\ %<\ %
autocmd FileType cpp setlocal makeprg=g++\ -o\ %<\ %
autocmd FileType java setlocal makeprg=java\ %

colorscheme industry

map <F2> :call SetTitle()<CR>
map <F5> :call Run()<CR>
map <F7> :make<CR><CR><CR> :cw<CR><CR>


func! Run()
   if &filetype == "java"
       exec "!java %<"
   endif
   if &filetype == "python"
       exec "!python %"
   endif
   exec "!./%<"
endfunc

func SetTitle()
    let l = 0
    let l = l + 1 | call setline(l,'/* **********************************************')
    let l = l + 1 | call setline(l,'Auther: haibin')
    let l = l + 1 | call setline(l,'Created Time: '.strftime('%c'))
    let l = l + 1 | call setline(l,'File Name   : '.expand('%'))
    let l = l + 1 | call setline(l,'*********************************************** */')
    if &filetype == "cpp"
        let l = l + 1 | call setline(l, '#include <iostream>')
        let l = l + 1 | call setline(l, '#include <cstring>')
        let l = l + 1 | call setline(l, '#include <cstdio>')
        let l = l + 1 | call setline(l, '#include <cstdlib>')
        let l = l + 1 | call setline(l, 'using namespace std;')
    endif
    if &filetype == "c"
        let l = l + 1 | call setline(l, '#include <stdio.h>')
        let l = l + 1 | call setline(l, '#include <string.h>')
        let l = l + 1 | call setline(l, '#include <stdlib.h>')
    endif
endfunc

inoremap ( ()<Esc>i
inoremap { {}<Esc>i<CR><Esc>
inoremap [ []<Esc>i
inoremap " ""<Esc>i