My Vimrc

set dir=~/.vim/swp
set backup
set backupdir=~/.vim/backup/
set backupext=.bak

set autoindent        "always set autoindenting on
set smartindent       "set smart indent
set smarttab          "use tabs at the start of a line, spaces elsewhere
set expandtab         "not use tab
set tabstop=4 softtabstop=4 shiftwidth=4

set smartcase
set ignorecase        " easier to ignore case for searching
set incsearch         " do incremental searching
set hlsearch          " highlighting the last used search pattern. or :noh
"set list             " show chars on end of line, whitespace, etc
"set nowrap           " do not wrap lines

set wildmenu          " command-line completion operates in an enhanced mode
set history=50        " keep 50 lines of command line history
set mouse=a           " set mouse functions

"don't make noise
set noerrorbells
set novisualbell


filetype on           " detect the type of file
syntax on             " syntax highlighting on
set fileformats=unix,dos
set textwidth=80          
set ruler             " show current positions along the bottom

set foldenable        " turn on folding
set foldmethod=indent " make folding indent sensitive
set foldlevel=100     " don't autofold anything
set foldopen-=search  " don't open folds when you search into them
set foldopen-=undo    " don't open folds when you undo stuff

"set encoding=prc
"set fileencoding=prc
"set fileencodings=prc

set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8

set guifont=Consolas\ 12
"set gfn=Consolas:h12 gfw=Consolas:h12

"auto change work dir
set autochdir

let Tlist_Ctags_Cmd = '/usr/bin/ctags'
map <F5> :VTreeExplore<CR>
map <F6> :TlistToggle<CR>
map <C-T> :tabnew<CR>
map <C-W> :tabclose<CR>
map <S-Left> :tabprev<CR>
map <S-Right> :tabnext<CR>
map <Left> :bp<CR>
map <Right> :bn<CR>
map <F4> :bd<CR>
map <C-Q> :bdelete<CR>
map <C-C> "+y<CR>
map <C-V> "+gP<CR>


"A collection of C extension Vim syntax. $HOME/.vim/after/syntax
let glib_enable_deprecated = 1
let glib_deprecated_errors = 1


au BufEnter * if &textwidth > 0 | exec 'match Todo /\%>' . &textwidth . 'v.\+/' | endif
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set shiftwidth=4
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set softtabstop=4
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set tabstop=4
au BufRead,BufNewFile *.py,*.pyw set expandtab                " not use tab
au BufRead,BufNewFile *.c,*.h set noexpandtab                 " use tab
au BufRead,BufNewFile Makefile* set noexpandtab
highlight BadWhitespace ctermbg=red guibg=red
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set textwidth=79
au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix


autocmd bufnewfile *.py call setline(1,'#! /usr/bin/env python') |
    \ call setline(2,'# -*- coding: utf-8 -*-') |
    \ call setline(3,'') |
    \ call setline(4, strftime("# Create Date: %F %T")) |
    \ call setline(5,'# Author: N23 <[email protected]>') |
    \ call setline(6,'# Blog: http://n23.appspot.com/blog') |
    \ call setline(7,'') |
    \ call setline(8,'') |
    \ exe "normal G"

"Python iMaps
au FileType python inoremap <buffer> $r return
au FileType python inoremap <buffer> $s self
au FileType python inoremap <buffer> $c ##<cr>#<space><cr>#<esc>kla
au FileType python inoremap <buffer> $f from
au FileType python inoremap <buffer> $i import
au FileType python inoremap <buffer> $p print
au FileType python inoremap <buffer> $d """<cr>"""<esc>O

"Java iMaps
autocmd FileType java inoremap <buffer> $pr private
autocmd FileType java inoremap <buffer> $r return
autocmd FileType java inoremap <buffer> $pu public
autocmd FileType java inoremap <buffer> $i import
autocmd FileType java inoremap <buffer> $b boolean
autocmd FileType java inoremap <buffer> $v void
autocmd FileType java inoremap <buffer> $s String
autocmd FileType java inoremap <buffer> $e Exception

augroup python_prog
  au!
  fun! Python_fold()
    execute 'syntax clear pythonStatement'
    execute 'syntax keyword pythonStatement break continue del'
    execute 'syntax keyword pythonStatement except exec finally'
    execute 'syntax keyword pythonStatement pass print raise'
    execute 'syntax keyword pythonStatement return try'
    execute 'syntax keyword pythonStatement global assert'
    execute 'syntax keyword pythonStatement lambda yield'
    execute 'syntax match pythonStatement /\<def\>/ nextgroup=pythonFunction skipwhite'
    execute 'syntax match pythonStatement /\<class\>/ nextgroup=pythonFunction skipwhite'
    execute 'syntax region pythonFold start="^\z(\s*\)\%(.*:\s*\%(#.*$\)\?\)" end="^\%(\n*\z1\s\)\@!" transparent fold'
    execute 'syntax sync minlines=2000 maxlines=4000'
    set autoindent
    set foldmethod=syntax
    " set foldopen=all foldclose=all
    set foldtext=substitute(getline(v:foldstart),'\\t','\ \ \ \ ','g').'\ \ ('.(v:foldend-v:foldstart+1).'\ lines)'
    set fillchars=vert:\|,fold:\
  endfun
  autocmd FileType python call Python_fold()
augroup END

"Make dir $HOME/.vim/after/syntax
"untar this file to $HOME/.vim/after/syntax
"If you don't have $HOME/.vim/after/syntax/c.vim,
"then copy c.vim.example to $HOME/.vim/after/syntax/c.vim

"see :h mysyntaxfile-add

"set csprg=/usr/local/bin/cscope
"set csto=1
"set nocsverb
"set cst
"cs add ~/.cscope/cscope.out
" ctrl + ]
" ctrl + t / ctrl + o
" cs find
" help cscope

"this script use to excute make in vim and open quickfix window
"map <C-M> :call Do_make()<CR><CR><CR>
"nmap B :call Do_make()<cr><cr><cr>
"nmap C :cclose<cr>
"function Do_make()
"  let filename = bufname("%")
"  let suffix_pos = stridx(filename, ".c")
"  if suffix_pos == -1
"      return
"  else
"      let target = strpart(filename,0,suffix_pos)
"  endif
"  let target = "make " . target
"  execute target
"  execute "copen"
"endfunction

"mkdir -p ~/.vim/templates
"let g:template_load = 1
"let g:template_tags_replacing = 1
"let g:T_AUTHOR = "N23"
"let g:T_AUTHOR_EMAIL = "[email protected]"
"let g:T_AUTHOR_WEBSITE = "http://blog.chinaunix.net/u1/42287/"
"let g:T_DATE_FORMAT = "%F %T"

"change work folder
"cd ~/tmp

"runtime! ftplugin/man.vim
"use :Man

"   vim *.c
"   :argdo %s/oldvalue/newvalue/g
"
"   %
"   =%
"   gg, G
"   [[, ]]
"   :reg
"     "a5yy
"     "ap
"     "A5yy
"     his c
"     his s
"     :1,5 co 10
"     q
"     :scriptnames
"     :digraphs
"     ga              " hex
"     :set noma       " non modifiable
"     :set ro         " read only
"     #session
"       vim file1.c file2.c
"       :mksession
"       :q
"       vim -S Session.vim
"
"       map : all
"       nmap: normal map
"       vmap: visual map
"       imap: insert map
"
"       b:name        " buffer
"       w:name        " window
"       g:name        " global
"       v:name        " vim
"       a:name        " function param
"
"     :set all
"     :list
"     :augroup

你可能感兴趣的:(C++,c,python,C#,vim)