个人VIMRC配置

syntax on                       " turn syntax highlighting on by default
"make vimrc enable imediately
autocmd BufWritePost $MYVIMRC source $MYVIMRC

"====================================================================
"set {{{1
"====================================================================
set lines=40 columns=180
"set fdm=indent
set foldmethod=marker
set ruler                       " show the cursor position all the time
set laststatus=2                " make the last line where the status is two lines deep so you can see status always
set backspace=indent,eol,start  " make that backspace key work the way it should
set nocompatible                " vi compatible is LAME
set showmode                    " show the current mode
"行号{
set nu!
"}
"菜单栏
set guioptions+=m
"设置字体{
"set guifont=Consolas:h9:cANSI
set guifont=Courier_New:h13
"set guifont=Courier\ New:h10:cANSI Consolas:h10:cANSI
"set guifont=Fixedsys:h12
"set guifont=Source\ Code\ Pro:h9
"}

"设置编码{
set encoding=utf-8
set fileencodings=utf-8,chinese
set termencoding=utf-8
if has("win32")
    set fileencoding=chinese
else
    set fileencoding=utf-8
endif

"解决菜单乱码
set imcmdline

set background=dark
set t_Co=256

"tab{
set tabstop=2
set expandtab
"}

set gcr=a:block-blinkon0

"path{
set path=./
"}

"{ gvim chinese-normal  but vim not
set termencoding=cp936
"}
"
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set tabstop=2
set softtabstop=2
set shiftwidth=2
"set noexpandtab
set expandtab
set autoindent
set cindent
set cc=80
set list
set listchars=tab:>-,trail:-

set nocompatible
set noswapfile
set nobackup
set nowritebackup
set noundofile

set virtualedit=all
"====================================================================
"set }}}1
"====================================================================

"====================================================================
"noremap {{{1
"====================================================================
noremap fd "+y
noremap ff *Nve
noremap fa "+p
nnoremap <C-S> :w<CR>
vnoremap <C-S> <C-C>:w<CR>
inoremap <C-S> <Esc>:w<CR>i<Esc>
"====================================================================
"noremap }}}1
"====================================================================

"====================================================================
"iabbrev {{{1
"====================================================================
iabbrev always always@(posedge clk or negedge rst_n)<CR>begin<CR>end<ESC>jkkA

"====================================================================
"iabbrev }}}1
"====================================================================

"====================================================================
"func!  {{{1
"====================================================================
filetype on
au BufRead,BufNewFile *.c set filetype=c
autocmd BufNewFile *.c exec ":call Settitle()"

func! Settitle()
          call setline (1,"//================================================================================")
          call append(line("."),"//Company:      ")
          call append(line(".")+1,"//Engineer:      yourname")
          call append(line(".")+2,"//Created Time:    ".strftime("%Y/%m/%d %H:%M"))
          call append(line(".")+3,"//File Name:     ".expand("%"))
          call append(line(".")+4,"//Project Name:")
          call append(line(".")+5,"//Target Devices:")
          call append(line(".")+6,"//Tool Versions:")
          call append(line(".")+7,"//Descriprition:")
          call append(line(".")+8,"//Revision:|".strftime("%Y/%m/%d %H:%M")."|wanghongbin")
          call append(line(".")+9,"//Additional Comments:")
          call append(line(".")+10,"//================================================================================")
endfunc

"====================================================================
"func!  }}}1
"====================================================================
language messages zh_CN.utf-8  "解决consle输出乱码
source $VIMRUNTIME/delmenu.vim
"source $VIMRUNTIME/menu.vim

source $VIMRUNTIME/vimrc_example.vim
"source $VIMRUNTIME/mswin.vim

"}
"behave mswin
"set guioptions-=m
"set guioptions-=T
set diffexpr=MyDiff()
function! MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let eq = ''
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      let cmd = '""' . $VIMRUNTIME . '\diff"'
      let eq = '"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction


"设置配色方案{
colorscheme desert "neon evening molokai solarized molokai github lucius desert
"colorscheme solarized molokai github lucius desert
"}



"ctrlp{  
let g:ctrlp_cmd = 'CtrlP'  
set wildignore+=*/Build-vc90/*,*.o,*.exe,*.git,*.pdb,*.bak,*.so,*.a
let g:ctrlp_by_filename = 1 " only lookup file name  
let g:ctrlp_max_height = 15  
let g:ctrlp_clear_cache_on_exit = 0  
let g:ctrlp_cache_dir = $HOME.'/.ctrlp/cache/'  
let g:ctrlp_working_path_mode = 'ra'  
let g:ctrlp_custom_ignore = {  
    \ 'dir':  '\v[\/]\.(git|hg|svn)$',  
    \ 'file': '\v\.(exe|so|dll|bak|gds|lib|suo|exp)$',  
    \ 'link': 'SOME_BAD_SYMBOLIC_LINKS',  
    \ }  
"}  

"ctags{
set tags=tags;
set autochdir
nnoremap <silent> <F12> :A<CR>
":set grepprg=grep\ -nri 
""""""""""""""""""""""""""""""
" Tag list (ctags)
""""""""""""""""""""""""""""""
"if has("win32")                "设定windows系统中ctags程序的位置
  let Tlist_Ctags_Cmd = 'ctags'
  let Tlist_Ctags_Cmd = 'D:/tools/gvim/vim73/ctags.exe'
"else               "设定windows系统中ctags程序的位置
"  let Tlist_Ctags_Cmd = '/usr/bin/ctags'
"endif
"

"Tagbar
let g:tagbar_ctags_bin='D:/tools/gvim/vim80/ctags.exe'
" end

let Tlist_Show_One_File = 1            "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow = 1          "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Use_Right_Window = 1         "在右侧窗口中显示taglist窗口
let Tlist_File_Fold_Auto_Close=1       "让不被编辑的文件的方法列表自动折叠起来
let Tlist_Show_Menu=1                  "显示taglist菜单
let Tlist_Auto_Open=0                  "启动vim自动启动TagList
"}
map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q.<CR>

" for vim-fugitive plugin{
" Added 16-Jun-2011: auto-cleans fugitive buffers From
" http://vimcasts.org/episodes/fugitive-vim-browsing-the-git-object-database/
autocmd BufReadPost fugitive://* set bufhidden=delete
"}
"
let g:ag_prg="ag.exe --column"
let g:ctrlsf_ackprg = 'ag'
let g:ctrlsf_auto_close = 0
let g:ctrlsf_context = '-B 5 -A 3'

"=====map shortcut=====
nnoremap <F3> :NormalGrepFile C W<cr>
vnoremap <F3> :<c-u>VisualGrepFile c w<cr>
nnoremap <F4> :NormalGrepFold C W *<cr>
vnoremap <F4> :<c-u>VisualGrepFold c w *<cr>
"=====command=====
"Grep in Folder
command! -nargs=* NormalGrepFold :call GrepHighlightFolder("n","",<f-args>)
command! -nargs=* VisualGrepFold :call GrepHighlightFolder("v","",<f-args>)
command! -nargs=+ GrepFold :call GrepHighlightFolder("n",<f-args>)
"Grep in File
command! -nargs=* NormalGrepFile :call GrepHighlightFile("n","",<f-args>)
command! -nargs=* VisualGrepFile :call GrepHighlightFile("v","",<f-args>)
command! -nargs=+ GrepFile :call GrepHighlightFile("n",<f-args>)
 
"=====func=====
function! GrepHighlightFile(...)
  call HighlightWord(a:1,a:2)
  if a:0 ==# 2
    call GrepInFile("c","w")
  else
    call GrepInFile(a:3,a:4)
  endif
endfunction
function! GrepHighlightFolder(...)
  call HighlightWord(a:1,a:2)
  if a:0 ==# 2
    call GrepInFolder("c","w","*")
  else
    call GrepInFolder(a:3,a:4,a:5)
  endif
endfunction
"highlight key word
function! HighlightWord(...)
  if a:1 ==? "n"
    if a:2 ==? ""
      execute "normal! yiw"
      let @/ = '\<' . @@ . '\>'
    else
      let @/ = a:2
    endif
 
  elseif a:1 ==? "v"
    execute "normal! `<v`>y"
    let @/ = @@
  endif
endfunction
 
"GrepInFile
function! GrepInFile(...)
  execute "normal! mM"
  if a:1 ==# "c"
    if a:2 ==# "w"
      execute 'normal! :vimgrep /' . @/ . '/ %' . "\<cr>"
    endif
  endif
  if a:1 ==# "c"
    if a:2 ==# "W"
      execute "normal! :vimgrep /\\<" . @/ . "\\>/ %\<cr>"
    endif
  endif
  if a:1 ==# "C"
    if a:2 ==# "w"
      execute "normal! :vimgrep /" . @/ . "\\C/ %\<cr>"
    endif
  endif
  if a:1 ==# "C"
    if a:2 ==# "W"
      execute "normal! :vimgrep /\\<" . @/ . "\\>\\C/ %\<cr>"
    endif
  endif
  execute "normal! `M"
endfunction
"Grep in Folder
function! GrepInFolder(...)
  execute "normal! mM"
  if a:1 ==# "c"
    if a:2 ==# "w"
      execute 'normal! :vimgrep /' . @/ . '/ **/' . a:3 . "\<cr>"
    endif
  endif
 
  if a:1 ==# "c"
    if a:2 ==# "W"
      execute 'normal! :vimgrep /\<" . @/ . '\>/ **/' . a:3 . "\<cr>"
    endif
  endif
  if a:1 ==# "C"
    if a:2 ==# "w"
      execute 'normal! :vimgrep /' . @/ . '\C/ **/' . a:3 . "\<cr>"
    endif
  endif
  if a:1 ==# "C"
    if a:2 ==# "W"
      execute 'normal! :vimgrep /\<' . @/ . '\>\C/ **/' . a:3 . "\<cr>"
    endif
  endif
  execute "normal! `M"
endfunction

"=================================================================
"显示行尾空格
"=================================================================
highlight WhitespaceEOL ctermbg=Cyan guibg=Cyan
match WhitespaceEOL /\s\+$/

log:

2022.5.31加入文件查找映射函数

2022.6.8
加入set virtualedit=all

2022.6.9加入显示行尾空格

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值