my _vimrc

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function! MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  if &sh =~ '/<cmd'
    silent execute '!""C:/Program Files/Vim/vim63/diff" ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . '"'
  else
    silent execute '!C:/Program" Files/Vim/vim63/diff" ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  endif
endfunction



"""""""""""""""""""""""""""""""""""""""""""""""""""""""
"                   customization
"""""""""""""""""""""""""""""""""""""""""""""""""""""""

"indent
set tabstop=4
set autoindent
set smartindent
set sw=4
set sta
set backspace=2

set nobackup

set ruler

set showcmd

set incsearch

" set path
"set path=.,$VIM,$CGIHOME,,
cd $HOME
set browsedir=current

"maximize
"au GUIEnter * simalt ~x

" remove menu
"set guioptions-=m

" remove toolbar
set guioptions-=T

"set gui font
set gfn=Courier_New:h12:cANSI
"set gfn=Crisp:h12

"showmatch
set sm

set lz "LazyRedraw (faster)
set mouse=a
set ic "ignore case for seaching
"set shortmess=at  "avoid 'press a key' promt
set noerrorbells  "don't make noise

"make it easier to access _vimrc
nmap ,s :source $VIM/_vimrc
nmap ,v :sp $VIM/_vimrc

"alignment
map <f3> gqipj
map <f12> :source C:/Program Files/Vim/vim63/syntax/2html.vim<cr>:w<cr>ZZ

" switch to current dir
autocmd BufEnter * :lcd %:p:h
"autocmd BufNewFile  *./(c/|cc/|cpp/|C/)  call C_CommentTemplates('cheader')
"autocmd BufNewFile  *./(h/|hpp/)         call C_CommentTemplates('hheader')

map <F6> :!cmd<CR>

if has('autocmd')
        " when event "set filetype" occurs (see :help filetype)
        autocmd Filetype asm call AsmDetected()
        autocmd Filetype perl call PerlDetected()
        autocmd Filetype java call JavaDetected()
        autocmd Filetype c call CDetected()
        autocmd Filetype cpp call CppDetected()
        autocmd Filetype python call PythonDetected()
        autocmd Filetype sql call SQLDetected()
        autocmd Filetype pascal call PasDetected()
        autocmd Filetype lisp call LispDetected()
endif

func! AsmDetected()
    map <F7> :w<CR>:!ml /c /coff /Cp "%"<CR>
    map <F8> :w<CR>:!link /subsystem:windows "%<.obj"<CR>
    map <F9> :w<CR>:!"%<"<CR>
endfunc

func! PerlDetected()
    map <F4> :call PerlDoc(expand("<cword>"))<CR>
    map <F7> :w<CR>:!perl -wd "%"<CR>
    map <F8> :w<CR>:!perl -wc "%"<CR>
    map <F9> :w<CR>:!perl "%"<CR>
    map <F11> :w<CR>:!perl "%"
    "autocmd BufUnload * call SetPerlExecutable()
    " useless in Windows
    set dictionary=$VIM/dict/Perl
    set complete+=k
endfunc

func! SetPerlExecutable()
    if synIDattr(synID(1,1,1),"name")=="perlSharpBang"
        exec ':!(if [ /! -x '.expand("<afile>").' ]; then chmod +x '.expand("<afile>").'; fi)'
    endif
endfunc

func! PerlDoc(keyword)
    if a:keyword=~"::"
            "module name;
            exec ':!perldoc '.a:keyword
    elseif a:keyword=~"^perl"
            "perl pod
            exec ':!perldoc '.a:keyword
    else
            "perl function
            exec ':!perldoc -f '.a:keyword
    endif
endfu

func! JavaDetected()
    map <F7> :w<CR>:!appletviewer "%"<CR>
    map <F8> :w<CR>:!javac -cp "%:p:h" "%"<CR>
    map <F9> :w<CR>:!java -cp "%:p:h" "%:r"<CR>
    "map <F8> :w<CR>:!javac -d classes -cp "%:p:h" "%"<CR>
    "map <F9> :w<CR>:!java -cp "%:p:h/classes" "%:r"<CR>

    map <F11> :w<CR>:!javac -Xlint:unchecked "%"<CR>

    set dictionary=$VIM/dict/Java
    set complete+=k
    "exec ':OUTLINE'

    iab psvmx public static void main(String[] args)
    iab soutnx System.out.println("
    iab soutx System.out.print("
endfunc

func! CDetected()
    "map <F8> :w<CR>:!cl "%"<CR>
    "for winsock program
    map <F8> :w<CR>:!gcc -o "%:r" "%"<CR>
    map <F9> :w<CR>:!"%<"<CR>
    set dictionary=$VIM/dict/C
    set complete+=k
    "exec ':OUTLINE'
endfunc

func! CppDetected()
    map <F8> :w<CR>:!g++ -o "%:r" "%"<CR>
    map <F9> :w<CR>:!"%<"<CR>
    set dictionary=$VIM/dict/C
    set complete+=k
    "exec ':OUTLINE'
endfunc

func! PythonDetected()
    map <F9> :w<CR>:!python "%"<CR>
    set dictionary=$VIM/dict/Python
    set complete+=k
endfunc

func! SQLDetected()
    map <F9> :call RunSql(getline('.'))<CR>
    map <F9> :call RunSql(getline('.'))<CR>
endfunc

func! RunSql(keyword)
    exec '!osql  /n /S.  /Usa /P /dpubs /Q"'.a:keyword.'"'
endfunc

func! PasDetected()
    set tabstop=2
    map <F8> :w<CR>:!dcc32 "%"<CR>
    map <F9> :w<CR>:!"%<"<CR>
endfunc

func! LispDetected()
    map <F9> :w<CR>:!clisp "%"<CR>
endfunc

""""""""""""    FOLDING     """"""""""""
"View the C++/C/Java folding file: C:/Program File/Vim/Vim63/plugin/outlinegottle.vim

"for C++ auto folding?? not very useful, but for learning how to do folding
"map <f5> :call FoldFunction()<cr>
func! FoldFunction()
        set foldmethod=syntax
        syntax region functionFold start="/(^/({/|/S.*{/)$/n/)/@<=/_[^}]" end="/(^{.*/)/@<!$/n/(^}/)/@=" transparent fold
endfunction

"general
iab ifx if ( ) {<cr>}<up><end><left><left><left><left>
iab elsex else {<cr>}<up><end><cr><bs><space><space><space>
iab forx for (int i = 0; i <; i++) {<cr>}<up><end><left><left><left><left><left><left><left><left>
iab whilex while ( ) {<return>}<up><end><left><left><left><left>
iab tryx try {<cr>} catch () {<cr>}<up><up><end><cr>
iab switchx switch ( ) {<cr>}<up><end><left><left><left><left>

"for perl
iab foreachx foreach () {<return>}<up><end><left><left><left><left><left>
iab elsifx elsif ( ) {<return>}<up><end><left><left><left><left>
iab subx sub {<return>}<up><end><left><left>
iab evalx eval {<cr>};<up><end><cr><bs><space><space><space>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值