觉得我现在的vim配置用起来不错
特意在这份想出来,也便于以后自己需要时使用
配置如下:
syntax on
colo evening
set nocompatible
set backspace=indent,eol,start
set number
set background=dark
set ruler
set showcmd
set noswapfile
set autoread
set nobackup
set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab
set smarttab
set mouse=a
set pastetoggle=<F3>
hi Normal ctermfg=252 ctermbg=none
filetype plugin indent on
inoremap ( ()<ESC>i//设置自动补全
inoremap [ []<ESC>i
inoremap { {}<ESC>i
inoremap < <><ESC>i
autocmd filetype c set makeprg=gcc\ -Wall\ -o%<\ %
autocmd filetype cppset makeprg=g++\ -Wall\ -o%<\ %
autocmd filetype javaset makeprg=javac\ %
autocmd filetype pythonset makeprg=python\ %
func! CompileCode()
exec "w"
exec "make"
exec "copen"
endfunc
func! ExecutePro()
if &filetype == 'c'
exec "!./%<"
endif
if &filetype == 'cpp'
exec "!./%<"
endif
if &filetype == 'java'
exec "!java %<"
endif
exec "cclose"
endfunc
map <F2> :call SetTitle()<CR>
func SetTitle()
let l = 0
let l = l + 1 | call setline(l,'/* ***********************************************')
let l = l + 1 | call setline(l,'Author :yinhua')
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,'************************************************ */')
let l = l + 1 | call setline(l,'')
let l = l + 1 | call setline(l,'#include <cmath>')
let l = l + 1 | call setline(l,'#include <cstdio>')
let l = l + 1 | call setline(l,'#include <string>')
let l = l + 1 | call setline(l,'#include <cstring>')
let l = l + 1 | call setline(l,'#include <iostream>')
let l = l + 1 | call setline(l,'#include <algorithm>')
let l = l + 1 | call setline(l,'using namespace std;')
let l = l + 1 | call setline(l,'')
let l = l + 1 | call setline(l,'int main() {')
let l = l + 1 | call setline(l,' ')
let l = l + 1 | call setline(l,' return 0;')
let l = l + 1 | call setline(l,'}')
endfunc
map <F9> :call CompileCode()<CR>
map! <F9> <ESC>:call CompileCode()<CR>
map <F12> :call ExecutePro()<CR>
map! <F12> <ESC>:call ExecutePro()<CR>