现在的位置: 首页 > 综合 > 正文

vim的配置文件

2013年09月02日 ⁄ 综合 ⁄ 共 2777字 ⁄ 字号 评论关闭

自己比较喜欢的一个vim的配置文件。

----------------_vimrc--------------------------

source$VIMRUNTIME/mswin.vim
behave mswin
imap <c-d> <c-o>dd
imap <cr> <cr><left><right>
map o o<left><right>
imap <c-]> {<cr>}<c-o>O<left><right>
noremap <f6> =a{
syn on
colo desert
filetype indent on
se ru nu ar sw=4 ts=4 noswf et sta nowrap ww=<,>,[,] gfn=Consolas:h12
autocmd BufEnter * lcd %:p:h
map <c-t> :tabnew<CR>

map <F2> :call SetTitle()<CR>Gkkk
func SetTitle()
let l = 0
let l = l + 1 | call setline(l, '/*')
let l = l + 1 | call setline(l, ' * Author:  mybestwishes')
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, '#include <iostream>')
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, '#include <cstring>')
let l = l + 1 | call setline(l, '#include <cmath>')
let l = l + 1 | call setline(l, '#include <algorithm>')
let l = l + 1 | call setline(l, '#include <string>')
let l = l + 1 | call setline(l, '#include <vector>')
let l = l + 1 | call setline(l, '#include <stack>')
let l = l + 1 | call setline(l, '#include <queue>')
let l = l + 1 | call setline(l, '#include <set>')
let l = l + 1 | call setline(l, '#include <time.h>')
let l = l + 1 | call setline(l, 'using namespace std;')
let l = l + 1 | call setline(l, 'const int maxint = -1u>>1;')
let l = l + 1 | call setline(l, '')
let l = l + 1 | call setline(l, 'int main() {')
let l = l + 1 | call setline(l, '    return 0;')
let l = l + 1 | call setline(l, '}')
let l = l + 1 | call setline(l, '')
echo l
endfun

map<F4> :call AddComment()<cr>
func AddComment()
    if matchstr(getline('.'), '[^ ]') == '/'
        normal ^xx
    else
        normal ^i//
    endif
endfunc
set printoptions=syntax:n,number:y,portrait:y

"设置vim根据编辑的文件自动切换工作目录
set autochdir

"设置水平滚动条
set guioptions+=b

"set encoding=utf-8
"set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1 " 如果你要打开的文件编码不在此列,那就添加进去"
set termencoding=utf-8

"F5编译当前的文件
map <F5> :call CompileGcc()<CR>
func! CompileGcc()
    exec "w"
    echo "file type:"&filetype
    if &filetype == 'c'
        exec "!gcc -o %:r.exe %:t"
"        exec "! %:r.exe"
    elseif &filetype == 'cpp'
        exec "!g++ -I\"D:\\boost_1_50_0\" -I\"C:\\Python32\\include\" -o %:r.exe %:t"
"        exec "! %:r.exe"
    elseif &filetype == 'java'
        exec "!javac %:t"
"        exec "!java %:r"
    elseif &filetype == 'bat'
        exec ":! %:t"
    elseif &filetype == 'python'
"    elseif "%:r" == "py"
        exec ":! %:t"
    endif
endfunc

" 运行
map <F9> :call RunGcc()<CR><CR>
func! RunGcc()
    if &filetype == 'c'
"        exec "! %:r.exe"
        if has('windows')  " 判断操作系统
     exec '!start cmd /c %:r.exe & pause'
 elseif has('linux')
     exec '!%:r.exe & pause'
 endif
    elseif &filetype == 'cpp'
"        exec "! %:r.exe"
        exec '!start cmd /c %:r.exe & pause'
    elseif &filetype == 'java'
"        exec "!java %:r"
        exec '!start cmd /c java %:r & pause'
    elseif &filetype == 'bat'
        exec "w"
" exec ":! %:t"
        exec '!start cmd /c %:t & pause'
    elseif &filetype == 'python'
"    elseif "%:r" == "py"
        exec "w"
" exec ":! %:t"
 exec '!start cmd /c %:t & pause'
    endif
endfunc

 

抱歉!评论已关闭.