Skip to content

Instantly share code, notes, and snippets.

@liuzhe0223
Created June 19, 2013 10:58
Show Gist options
  • Save liuzhe0223/5813470 to your computer and use it in GitHub Desktop.
Save liuzhe0223/5813470 to your computer and use it in GitHub Desktop.
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'rails.vim'
Bundle 'c.vim'
Bundle 'python.vim'
"Bundle 'https://github.com/ervandew/supertab.git'
Bundle 'git://github.com/scrooloose/nerdtree.git'
Bundle 'git://github.com/mattn/zencoding-vim.git'
Bundle 'git://github.com/tpope/vim-rails.git'
Bundle 'git://github.com/kien/ctrlp.vim.git'
Bundle 'vim-ruby'
Bundle 'vim-coffee-script'
Bundle 'git://github.com/Yggdroot/indentLine.git'
Bundle 'https://github.com/vim-scripts/Auto-Pairs.git'
Bundle 'https://github.com/vim-scripts/pythoncomplete.git'
Bundle 'https://github.com/Shougo/neocomplcache.git'
Bundle 'https://github.com/vim-scripts/snipMate.git'
autocmd FileType python set ft=python.django " For SnipMate
autocmd FileType html set ft=htmldjango.html " For SnipMate
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_enable_smart_case = 1
syntax enable
filetype indent on
au BufRead,BufNewFile *.go set filetype=go
set nu
set enc=Chinese tenc=UTF-8
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set shiftwidth=4
set tabstop=4
let NERDTreeIgnore = ['\.pyc$'] "忽略python的字节码文件
autocmd vimenter * if !argc() | NERDTree | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
inoremap jj <ESC>
"vimim
let g:vimim_plugin = '~/.vim/bundle/VimIM/plugin'
imap <C-\> <C-_>
let g:rsenseHome = "/opt/rsense-0.3"
let g:rsenseUseOmniFunc = 1
map <F8> :call FormartSrc()<CR>
"定义FormartSrc()
func FormartSrc()
exec "w"
if &filetype == 'c'
exec "!astyle --style=ansi --one-line=keep-statements -a --suffix=none %"
elseif &filetype == 'cpp' || &filetype == 'hpp'
exec "r !astyle --style=ansi --one-line=keep-statements -a --suffix=none %> /dev/null 2>&1"
elseif &filetype == 'perl'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'py'||&filetype == 'python'
exec "r !pydent % > /dev/null 2>&1"
elseif &filetype == 'java'
exec "!astyle --style=java --suffix=none %"
elseif &filetype == 'jsp'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'xml'
exec "!astyle --style=gnu --suffix=none %"
endif
exec "e! %"
endfunc
"结束定义FormartSrc
map <F12> :call RunSrc()<CR>
"定义FormartSrc()
func RunSrc()
exec "w"
if &filetype == 'c'
exec "!astyle --style=ansi --one-line=keep-statements -a --suffix=none %"
elseif &filetype == 'cpp' || &filetype == 'hpp'
exec "r !astyle --style=ansi --one-line=keep-statements -a --suffix=none %> /dev/null 2>&1"
elseif &filetype == 'perl'
exec "!astyle --style=gnu --suffix=none %"
elseif &filetype == 'py'||&filetype == 'python'
exec "!python %"
elseif &filetype == 'java'
exec "!astyle --style=java --suffix=none %"
endif
exec "e! %"
endfunc
"结束定义FormartSrc
"
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" python filetype
function HeaderPython()
call setline(1, "#!/usr/bin/env python2")
call append(1, "# -*- coding: utf-8 -*-")
call append(2, "# Pw @ " . strftime('%Y-%m-%d %T', localtime()))
normal G
normal o
normal o
endf
autocmd bufnewfile *.py call HeaderPython()
"python tab
:set ts=4
:set expandtab
:%retab!%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment