常用vimrc脚本

来源:互联网 发布:三菱fx系列编程手册 编辑:程序博客网 时间:2024/06/05 14:56

     忘了从哪儿扣了,非常不错:

      " Wrap too long lines
set wrap


" Tabs are 4 characters
set tabstop=4


" (Auto)indent uses 4 characters
set shiftwidth=4


" make backup
"set backup


" backup dir
"set backupdir=~/tmp


" spaces instead of tabs
set expandtab


" show tab
" set list listchars=tab:>-


" guess indentation
set autoindent


" Expand the command line using tab
set wildchar=<Tab>


" show line numbers
"set number


" Fold using markers {{{
" like this
" }}}
set foldmethod=marker


" utf8 encode
set enc=utf-8


set viminfo='10,\"1000,:20,%,n~/.viminfo


" enable all features
set nocompatible


" powerful backspaces
set backspace=indent,eol,start


" highlight the searchterms
set hlsearch


" jump to the matches while typing
set incsearch


" ignore case while searching
set ignorecase


" don't wrap words
set textwidth=0


" history
set history=200


" 1000 undo levels
set undolevels=1000


" show a ruler
set ruler


" show partial commands
set showcmd


" show matching braces
set showmatch


" write before hiding a buffer
set autowrite


" allows hidden buffers to stay unsaved, but we do not want this, so comment
" it out:
"set hidden


"set wmh=0


" ctags
set tags=tags;
set tagstack            "lets you push and pop your jumps with ctrl+]


set autochdir


" auto-detect the filetype
filetype plugin indent on


" trailing space
let c_space_errors=1


" syntax highlight
syntax on


" we use a dark background, don't we?
set bg=dark


" Always show the menu, insert longest match
set completeopt=menuone,longest


"dictionary word autocomplete. type <CTL-N> in the middle of a word to use
set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words
set complete-=k complete+=k




" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
  \ if line("'\"") > 0 && line("'\"") <= line("$") |
  \   exe "normal g`\"" |
  \ endif




"don't expand tabs if we're in a makefile
au BufRead,BufNewFile Makefile set ts=4 sw=4 noexpandtab


autocmd BufNewFile,BufRead *.txt set tw=78
autocmd BufNewFile,BufRead *.tex set tw=80


"good tab completion - press <tab> to autocomplete if there's a character
"previously
function InsertTabWrapper()
      let col = col('.') - 1
      if !col || getline('.')[col - 1] !~ '\k'
          return "\<tab>"
      else
          return "\<c-p>"
      endif
endfunction


inoremap <tab> <c-r>=InsertTabWrapper()<cr>


if has("cscope")
    set csprg=/usr/bin/cscope
    set cspc=0
    set csto=0
    set cst
    set nocsverb
    if filereadable("cscope.out")
        cs add cscope.out $PWD/.
    elseif filereadable("../cscope.out")
        cs add ../cscope.out $PWD
    elseif filereadable("../../cscope.out")
        cs add ../../cscope.out $PWD
    elseif filereadable("../../../cscope.out")
        cs add ../../../cscope.out $PWD
    elseif filereadable("../../../../cscope.out")
        cs add ../../../../cscope.out $PWD
    " else add database pointed to by environment
    elseif $CSCOPE_DB != ""
        cs add $CSCOPE_DB $CSCOPE_DB
    endif
    set csverb


    "   's'   symbol: find all references to the token under cursor
    "   'g'   global: find global definition(s) of the token under cursor
    "   'c'   calls:  find all calls to the function name under cursor
    "   't'   text:   find all instances of the text under cursor
    "   'e'   egrep:  egrep search for the word under cursor
    "   'f'   file:   open the filename under cursor
    "   'i'   includes: find files that include the filename under cursor
    "   'd'   called: find functions that function under cursor calls
    nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
    nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
    nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
    nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
endif

0 0
原创粉丝点击