常用vimrc脚本
2015-06-11 13:11
225 查看
忘了从哪儿扣了,非常不错:
" 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
" 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
相关文章推荐
- 40 Key Computer Science Concepts Explained In Layman’s Terms
- ExtJs自学教程(1):从一切API开始
- android service详解
- ASCII对照表
- Android Studio 快捷键
- 如何改变Myeclipse编辑区背景色
- jqgrid 动态列生成
- 模仿猫眼电影App一个动画效果
- 印象笔记以PDF导出笔记
- 防御XSS的七条原则
- Unable to resolve target 'android-XX'
- 什么是Java垃圾回收器
- chorme浏览器div包含img标签页面总超出浏览器页面高度
- png图片压缩
- 匈牙利算法
- XAMPP Linux
- android获取view高度方法
- web 应用 为啥 需要用到 tomcat 之类的 部署
- 如果这纷乱的世界让我沮丧,我就去看看她们眼中的光芒
- 基于jquery的ajax 异步获取json