My Vimrc

一半是自己的内容,另一半是升级后被自动merge过来的,懒得整理了,还算好用,备份下

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"关闭兼容模式
set nocompatible " get out of horrible vi-compatible mode
"设置历史
set history=100 " How many lines of history to remember
set ffs=unix,dos,mac " support all three, in this order
"文件类型识别
filetype on " detect the type of file
filetype plugin indent on " load filetype plugins
"转换成unix换行符(其他可选值:mac,dos)
set fileformat=unix
"外部修改时自动读取
"set autoread
set viminfo+=! " make sure it can save viminfo
set isk+=_,$,@,%,#,- " none of these should be word dividers, so make them not be
set helplang=cn " chinese help
"自动补全
set completeopt=longest,menu " for omnipotent
"设置shell
set shell=bash

let g:LookupFile_TagExpr = '"./tags'

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Theme/Colors
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set background=dark " we are using a dark background
syntax on " syntax highlighting on
if has("gui_running")
    set guifont=Bitstream\ Vera\ Sans\ Mono\ 12
    colorscheme desert
else
    "colorscheme pablo
    "colorscheme desert
    colorscheme default
    "colorscheme evening
endif

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Files/Backups
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nobackup " make backup file
set autowrite  " auto writefile when sth happened such as :make or :last or others.See the help
set makeef=error.err " When using make, where should it dump the file

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim UI
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"增强命令行补全
set wildmenu " turn on wild menu
"显示光标位置
set ruler " Always show current positions along the bottom
"设置命令行高度
set cmdheight=1 " the command bar is 1 high
"set nonumber " turn off line numbers
"显示行号
set number
set numberwidth=4 " minimum width to use for the number column,not a fix size
set hid " you can change buffer without saving
"设置退格键
set backspace=eol,start,indent
"set backspace=2 " make backspace work normal
"设置跨行键
set whichwrap+=<,>,h,l  " backspace and cursor keys wrap to
"set mouse=a " use mouse everywhere
set shortmess=atI " shortens messages to avoid 'press a key' prompt
set report=0 " tell us when anything is changed via :...
"减少刷新和重画
set lz " do not redraw while running macros (much faster) (LazyRedraw)
" make the splitters between windows be blank
set fillchars=vert:\ ,stl:\ ,stlnc:\
set lsp=0 " space it out a little more (easier to read)
"搜索时忽略大小写
set ignorecase

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Visual Cues
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"自动匹配括号
set showmatch " show matching brackets
set mat=2
"搜索时高亮关键字
set hlsearch " do highlight searched for phrases
"设置magic
"set magic
set incsearch " BUT do highlight as you type you search phrase
set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ " what to show when I hit :set list
set so=2 " Keep 2 lines (top/bottom) for scope
"关闭提示音
set novisualbell " don't blink
set noerrorbells " no noises for error
set vb t_vb=     " no noises for other

"状态条
set laststatus=2 " always show the status line

"设置颜色主题
set t_Co=256
"高亮当前行
"set cursorline
"高亮菜单
hi Pmenu guibg=#333333
hi PmenuSel guibg=#555555 guifg=#ffffff

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" File encode
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set encoding=utf-8
set fileencoding=chinese
set fileencodings=ucs-bom,utf-8,chinese
language message zh_CN.UTF-8

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Text Formatting/Layout
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set formatoptions+=mM " for charactors fold and patch
set ai " autoindent
set si " smartindent
"C风格缩进
set cindent " do c-style indenting
set tabstop=4 " tab spacing (settings below are just to unify it)
set softtabstop=4 " unify
set shiftwidth=4 " unify
set expandtab " no real tabs please!
"set nowrap " do not wrap lines  
set smarttab " use tabs at the start of a line, spaces elsewhere
"set dictionary=/usr/share/dict/american-english "use dictionary when input the english word
set dictionary=/home/dig/vim_dict/gtk

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Folding
" Enable folding, but by default make it act like folding is off, because folding is annoying in anything but a few rare cases
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set foldenable " Turn on folding
set foldlevel=100 " Don't autofold anything (but I can still fold manually)
set foldopen-=search " don't open folds when you search into them
set foldopen-=undo " don't open folds when you undo stuff

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" File Explorer
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:explVertical=1 " should I split verticially
let g:explWinSize=35 " width of 35 pixels

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Win Manager
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:winManagerWidth=35 " How wide should it be( pixels)
let g:winManagerWindowLayout = 'FileExplorer|TagList,TagsExplorer|BufExplorer' " What windows should it
let g:persistentBehaviour=0
:set cscopequickfix=s-,c-,d-,i-,t-,e-

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CTags and Taglist
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"设置Tlist
let Tlist_Ctags_Cmd = "/usr/bin/ctags-exuberant" " Location of my ctags
let Tlist_Sort_Type = "name" " order by
let Tlist_Use_Right_Window = 0 " split to the left side of the screen
let Tlist_Use_SingleClick=1
let Tlist_Auto_Highlight_Tag=1
let Tlist_Compart_Format = 1 " show small meny
"let Tlist_Exist_OnlyWindow = 1 " if you are the last, kill yourself
let Tlist_Exit_OnlyWindow = 1 " if you are the last, kill yourself
let Tlist_File_Fold_Auto_Close = 0 " Do not close tags for other files
let Tlist_Enable_Fold_Column = 0 " Do not show folding tree
let Tlist_Show_One_File = 1 " only display the tag of current file
let tlist_make_settings='make;m:makros;t:targets'
let tlist_qmake_settings='qmake;t:SystemVariables'
:

"set tags=./tags,./../tags,./../../tags,./**/tags,tags,/opt/xilinx/edk91/sw/tags "/usr/include/tags " which tags files CTRL-] will search
set tags=./tags,./../tags,./../../tags,./../../../tags,./../../../../tags,./../../../../../tags,./**/tags,
set autochdir " auto change the current dierctory when you open the file or window or any other buffer
set makeef=makeerror.err
set path=.,./../**,/usr/include/*,,

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Minibuf
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:miniBufExplTabWrap = 1 " make tabs show complete (no broken on two lines)
let g:miniBufExplModSelTarget = 1

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Matchit
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"let b:match_ignorecase = 1
"let b:match_ignorecase = 1

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Mappings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"map <right> <ESC><C-PageDown> " right arrow (normal mode) switches tabs
"map <left>  <ESC><C-PageUp>   " left arrow (normal mode) switches tabs
"inoremap <F8> ^X^O^[             " F8 to omni completion
"map <silent> <F1> :TlistToggle<ESC>" F9 to toggle the taglist  
map <F3>    ^i//<ESC>         " insert remark flag
map <F4>    :s?\/\/??<ESC>    " delete remark flag
"map <up> <ESC>:Sex<RETURN><ESC><C-W><C-W> " up arrow (normal mode) brings up a file list
"map <down> <ESC>:Tlist<RETURN> " down arrow  (normal mode) brings up the tag list
"map <F12> ggVGg? " encypt the file (toggle)
map <F5> :q!<ESC>
map <F7> :TlistToggle<ESC>
map <F8> ::Explore<ESC>

map <C-f> :lv /<c-r>=expand("<cword>")<cr>/ %<cr>:lw<cr>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Autocommands
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
au BufEnter /usr/include/c++/*   setf cpp " all the file under the directory are recognized as cpp files by vim

au filetype c,cpp,cc,h,v map <F3>    ^i//<ESC>          " insert remark flag ,for c/c++/verilog
au filetype c,cpp,cc,h,v map <F4>    :s?\/\/??<RETURN>:nohl<ESC>   " delete remark flag ,for c/c++/verilog
au BufRead,BufNewFile  *vimrc*,*.vim map <F3>    ^i"<ESC>         " insert remark flag ,for vim script
au BufRead,BufNewFile  *vimrc*,*.vim map <F4>    :s?"??<RETURN>:nohl<ESC>  " delete remark flag ,for vim script

" vim -b : edit binary using xxd-format!
augroup Binary
        au!
        au BufReadPre  *.bin let &bin=1
        au BufReadPost *.bin if &bin | %!xxd
        au BufReadPost *.bin set ft=xxd | endif
        au BufWritePre *.bin if &bin | %!xxd -r
        au BufWritePre *.bin endif
        au BufWritePost *.bin if &bin | %!xxd
        au BufWritePost *.bin set nomod | endif
augroup END

" if there are any error space(the end of line or before the tabs) in c/c++ code,highlight it
"if $VIM_HATE_SPACE_ERRORS != '0'
"let c_space_errors=1
"endif

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Useful abbrevs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
iab #in #include
iab #de #define
"iab xasp <%@language=jscript%><CR><%<CR><TAB><CR><BS>%><ESC><<O<TAB>
"iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
"iab { {^M}^[
"iab ( ()^[i
"iab [ []^[i

:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap < <><ESC>i
:inoremap > <c-r>=ClosePair('>')<CR>

function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf


"Switch tabs use Alt+n
function! BufPos_ActivateBuffer(num)
    let l:count = 1
    for i in range(1, bufnr("$"))
        if buflisted(i) && getbufvar(i, "&modifiable")
            if l:count == a:num
                exe "buffer " . i
                return
            endif
            let l:count = l:count + 1
        endif
    endfor
    echo "No buffer!"
endfunction

function! BufPos_Initialize()
    for i in range(1, 9)
        exe "map <M-" . i . "> :call BufPos_ActivateBuffer(" . i . ")<CR>"
    endfor
    exe "map <M-0> :call BufPos_ActivateBuffer(10)<CR>"
endfunction

autocmd VimEnter * call BufPos_Initialize()

"当.vimrc 改变时,自动重载
"autocmd! bufwritepost vimrc source ~/.vimrc

"paste toggle - when pasting someting in, don't indent.
set pastetoggle=
"super paste
inoremap  :set pastemui+mv'uV'v=:set nopaste
"生成CTags
map ctg :!ctags-exuberant -R
"map ctg :!ctags-exuberant -R --extra=+q:TlistUpdate


au BufNewFile,BufRead *.aidl  set ft=java

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值