zoukankan      html  css  js  c++  java
  • 贴个自个用的vimrc zmlovelx(帅得不敢出门 c/c++群31843264) 博客频道 CSDN.NET

    贴个自个用的vimrc - zmlovelx(帅得不敢出门 c/c++群31843264) - 博客频道 - CSDN.NET

    贴个自个用的vimrc

    分类: Vim 151人阅读 评论(0) 收藏 举报
    1. " ~/.vimrc (configuration file for vim only)  
    2.   
    3. set fileencodings=utf-8,gb2312,gbk,gb18030  
    4. set termencoding=utf-8  
    5.   
    6. "vundle begin 插件管理  
    7. filetype off                   " required!  
    8.   
    9. set rtp+=~/.vim/bundle/vundle/  
    10. call vundle#rc()  
    11.   
    12. " let Vundle manage Vundle  
    13. " required!   
    14. Bundle 'gmarik/vundle'  
    15. " vim-scripts repos  
    16. Bundle 'STL-improved'  
    17. Bundle 'taglist.vim'  
    18. Bundle 'tag_in_new_tab'  
    19. Bundle 'autoload_cscope.vim'  
    20. Bundle 'CmdlineComplete'  
    21. Bundle 'xptemplate'  
    22. Bundle 'neocomplcache'  
    23. Bundle 'genutils'  
    24. Bundle 'lookupfile'  
    25. Bundle 'autopreview'  
    26. Bundle 'echofunc.vim'  
    27. Bundle 'grep.vim'  
    28. Bundle 'a.vim'  
    29. Bundle 'The-NERD-Commenter'  
    30. Bundle 'The-NERD-tree'  
    31. Bundle 'Source-Explorer-srcexpl.vim'  
    32. Bundle 'trinity.vim'  
    33. "under linux need exec 'dos2unix ~/.vim/bundle/QFixToggle/plugin/qfixtoggle.vim'  
    34. Bundle 'QFixToggle'  
    35. Bundle 'Color-Sampler-Pack'  
    36. Bundle 'txt.vim'  
    37. Bundle 'mru.vim'  
    38. Bundle 'Align'  
    39. Bundle 'DoxygenToolkit.vim'  
    40. Bundle 'headerGatesAdd.vim'  
    41. Bundle 'ShowMarks'  
    42. " non github repos  
    43. " autocomplete.match.pair.vim,这个安装完必须在.vim/bundle/449512/目录下创建plugin目录并在其下创建软链接指向autocomplete.match.pair.vim,否则不工作,另外不知为何(号不会自动完成配对  
    44. Bundle 'git://gist.github.com/449512.git'  
    45. " ...  
    46. filetype plugin indent on     " required!   
    47. "vundle end  
    48.   
    49. colorscheme desert   
    50. syn on "显高亮  
    51. "set ruler  "屏幕右下角显示当前光标所处位置  
    52. set laststatus=2 " always have status-line'  
    53. set statusline=%F%m%r%h%w\ %{&ff}\ %Y\ [ascii:%b\ hex:0x\%02.2B]\ [%{(&fenc\ ==\ \"\"?&enc:&fenc).(&bomb?\",BOM\":\"\")}]\ %=%l/%L,%v\ %p%%  
    54. set number  
    55. set autochdir          " 自动切换当前目录为当前文件所在的目录  
    56. set autoread           " 文件被其他程序修改时自动载入  
    57.   
    58. " Lines folding  
    59. "set foldenable  
    60. "set foldnestmax=1  
    61. "set foldmethod=syntax  
    62. "set foldlevel=1  
    63.   
    64. " allow backspacing over everything in insert mode  
    65. set backspace=indent,eol,start  
    66.   
    67. set shiftwidth=4  
    68. set tabstop=4  
    69. set softtabstop=4  
    70. set expandtab  
    71. set list                     " 显示Tab符,使用一高亮竖线代替  
    72. set listchars=tab:\|\ ,  
    73.   
    74. " http://vimcdoc.sourceforge.net/doc/indent.html  
    75. " g0 类的public顶格写  
    76. " :0 将 case 标号放在 switch() 缩进位置之后的 N 个字符处  
    77. " N-s namespace 下顶格  
    78. " (0  条件语句多个条件在不同行时下一行与上一行对齐  
    79. set cinoptions=g0,:0,N-s,(0  
    80. set autoindent  
    81. set smartindent  
    82. "set mouse=a  
    83.   
    84. set mps+=<:>            "让<>可以使用%跳转  
    85. set hid " allow to change buffer without saving   
    86. set shortmess=atI " shortens messages to avoid 'press a key' prompt   
    87. set lazyredraw "do not redraw while executing macros (much faster)  
    88. " Set Number format to null(default is octal) , when press CTRL-A on number  
    89. " like 007, it would not become 010  
    90. set nf=  
    91. " In Visual Block Mode, cursor can be positioned where there is no actual character  
    92. set ve=block  
    93. set ignorecase " Set search/replace pattern to ignore case   
    94. set smartcase " Set smartcase mode on, If there is upper case character in the search patern, the 'ignorecase' option will be override.  
    95. set showcmd     " display incomplete commands  
    96. set incsearch       " do incremental searching  
    97. set hlsearch  "highlight search  
    98. set magic   " Enable magic matching  
    99. set showmatch " show matching paren  
    100. set wildmenu "增强模式中的命令行自动完成操作  
    101.   
    102. " Auto change the root directory  
    103. let NERDTreeChDirMode=2  
    104.   
    105. let g:DoxygenToolkit_blockHeader="--------------------------------------------------------------------------"  
    106. let g:DoxygenToolkit_blockFooter="--------------------------------------------------------------------------"  
    107. let g:DoxygenToolkit_authorName="帅得不敢出门 c++群31843264"   
    108. let g:DoxygenToolkit_versionString="0.1.00"  
    109. let g:DoxygenToolkit_briefTag_funcName="yes"  
    110. autocmd BufNewFile *.{h,hpp,c,cpp} DoxAuthor   
    111.   
    112. " <Space> key at normal model.    
    113. "nnoremap <Space> i <Esc>l  
    114.     
    115. " Switching between buffers.   
    116. nnoremap <C-h> <C-W>h  
    117. nnoremap <C-j> <C-W>j  
    118. nnoremap <C-k> <C-W>k  
    119. nnoremap <C-l> <C-W>l  
    120. inoremap <C-h> <Esc><C-W>h  
    121. inoremap <C-j> <Esc><C-W>j  
    122. inoremap <C-k> <Esc><C-W>k  
    123. inoremap <C-l> <Esc><C-W>l  
    124.   
    125. " Set Up and Down non-linewise  
    126. noremap <Up> gk  
    127. noremap <Down> gj  
    128.   
    129. " use Meta key(Windows:Alt) to move cursor in insert mode.   
    130. " Note: if system install "Lingoes Translator",   
    131. "   you will need change/disabled hot key.   
    132. noremap! <M-j> <Down>  
    133. noremap! <M-k> <Up>  
    134. noremap! <M-h> <left>  
    135. noremap! <M-l> <Right>  
    136.   
    137. set pastetoggle=<F2>  
    138. "nnoremap <F2> :set invnumber number?<CR>:set invpaste paste?<CR>  
    139. "imap <F2> <C-O>:set invpaste paste?<CR><C-O>:set invnumber number?<CR>  
    140. nnoremap <silent> <F3> :Rgrep<CR>  
    141. nnoremap <F6> :AutoPreviewToggle<CR>  
    142. inoremap <F6> <ESC>:AutoPreviewToggle<CR>i   
    143. " Open and close all the three plugins on the same time   
    144. nmap <F8>   :TrinityToggleAll<CR>  
    145. " Open and close the srcexpl.vim separately   
    146. nmap <F7>   :TrinityToggleSourceExplorer<CR>  
    147. " Open and close the taglist.vim separately   
    148. nmap <F10>  :TrinityToggleTagList<CR>  
    149. " Open and close the NERD_tree.vim separately   
    150. nmap <F11>  :TrinityToggleNERDTree<CR>  
    151.   
    152. " --lookupfile--  
    153. let g:LookupFile_MinPatLength = 2               "最少输入2个字符才开始查找   
    154. let g:LookupFile_PreserveLastPattern = 0        "不保存上次查找的字符串   
    155. "let g:LookupFile_PreservePatternHistory = 1     "保存查找历史   
    156. let g:LookupFile_AlwaysAcceptFirst = 1          "回车打开第一个匹配项目   
    157. let g:LookupFile_AllowNewFiles = 0              "不允许创建不存在的文件   
    158. if filereadable("./filenametags")                "设置tag文件的名字  
    159. let g:LookupFile_TagExpr ='"./filenametags"'  
    160. endif  
    161.   
    162. " -- taglist --  
    163. set tags=tags;  
    164. let Tlist_Auto_Update=1  
    165.   
    166. " -- cscope --  
    167. let g:autocscope_menus=0  
    168. " Use quickfix window to show cscope results  
    169. set cscopequickfix=s-,g-,d-,c-,t-,e-,f-,i-  
    170.   
    171. "'csto' 被设为 0,cscope 数据库先 被搜索,搜索失败的情况下在搜索标签文件   
    172.  "设定了 'cscopetag',这样所有的 :tag 命令就会实际上调用 :cstag。这包括 :tag、Ctrl-] 及 vim -t。  
    173.  "结果是一般的 tag 命令不仅搜索由 ctags 产生的标签文 件,同时也搜索 cscope 数据库,但是好像有bug,二者共存时有的无法搜索  
    174.  if has("cscope")   
    175.     set csprg=/usr/bin/cscope  
    176.     " Use both cscope and ctag  
    177.     set cscopetag  
    178.     " Show msg when cscope db added  
    179.     set cscopeverbose  
    180.     " Use cscope for definition search first  
    181.     set cscopetagorder=0  
    182.  endif  
    183.   
    184.  nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>  
    185.  nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>  
    186.  nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>  
    187.  nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>  
    188.  nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>  
    189.  nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>  
    190.  nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>{1}lt;CR>  
    191.  nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>  
    192.   
    193.  " 解决cscope与tag共存时ctrl+]有时不正常的bug  
    194.  nmap <C-]> :tj <C-R>=expand("<cword>")<CR><CR>  
    195.   
    196. " VimTip 329: A map for swapping words   
    197.  " http://vim.sourceforge.net/tip_view.php?tip_id=   
    198.  " Then when you put the cursor on or in a word, press "\sw", and   
    199.  " the word will be swapped with the next word.  The words may   
    200.  " even be separated by punctuation (such as "abc = def").   
    201.  nnoremap <unique> <silent><leader>sw "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/<cr><c-o>  
    202.   
    203. " Disable AutoComplPop.  
    204. let g:acp_enableAtStartup = 0  
    205. " Use neocomplcache.  
    206. let g:neocomplcache_enable_at_startup = 1  
    207. " Use smartcase.  
    208. let g:neocomplcache_enable_smart_case = 1  
    209. " Use camel case completion.  
    210. let g:neocomplcache_enable_camel_case_completion = 1  
    211. " Use underbar completion.  
    212. let g:neocomplcache_enable_underbar_completion = 1  
    213. " Set minimum syntax keyword length.  
    214. let g:neocomplcache_min_syntax_length = 3  
    215. let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'  
    216. let g:neocomplcache_enable_ignore_case = 0  
    217.   
    218. " Define dictionary.  
    219. let g:neocomplcache_dictionary_filetype_lists = {  
    220.     \ 'default' : '',  
    221.     \ 'vimshell' : $HOME.'/.vimshell_hist',  
    222.     \ 'scheme' : $HOME.'/.gosh_completions'  
    223.     \ }  
    224.   
    225. " Define keyword.  
    226. if !exists('g:neocomplcache_keyword_patterns')  
    227.   let g:neocomplcache_keyword_patterns = {}  
    228. endif  
    229. let g:neocomplcache_keyword_patterns['default'] = '\h\w*'  
    230.   
    231. " Recommended key-mappings.  
    232. " <CR>: close popup and save indent.  
    233. inoremap <expr><CR>  neocomplcache#smart_close_popup() . "\<CR>"  
    234. " <TAB>: completion.  
    235. "inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"  
    236. " <C-h>, <BS>: close popup and delete backword char.  
    237. inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"  
    238. inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"  
    239. inoremap <expr><C-y>  neocomplcache#close_popup()  
    240. inoremap <expr><C-e>  neocomplcache#cancel_popup()  
    241.   
    242. "Fast remove highlight search  
    243. nmap <silent> <leader><cr> :noh<cr>  
    244.   
    245. " 每行超过80个的字符用下划线标示  
    246. au BufRead,BufNewFile *.asm,*.c,*.cpp,*.java,*.cs,*.sh,*.lua,*.pl,*.pm,*.py,*.rb,*.hs,*.vim 2match Underlined /.\%81v/  
    247. " 超过80个的字符高亮  
    248. "au BufWinEnter * let w:m1=matchadd('Search', '\%<88v.\%>81v', -1)  
    249. "au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)  
    250.   
    251. "高亮显示txt 需要txt.vim  
    252. au BufRead,BufNewFile * setfiletype txt  
    253.   
    254. " Restore the last quit position when open file.   
    255.  autocmd BufReadPost *   
    256.     \ if line("'\"") > 0 && line("'\"") <= line("{1}quot;) |   
    257.      \     exe "normal g'\"" |   
    258.      \ endif  
    259.   
    260. " 自动更新最后修改时间  
    261. function! AutoUpdateTheLastUpdateInfo()  
    262.     let s:original_pos = getpos(".")  
    263.     let s:regexp = "^\\s*\\([#\\\"\\*]\\|\\/\\/\\)\\s\\?[lL]ast \\([uU]pdate\\|[cC]hange\\):"  
    264.     let s:lu = search(s:regexp)  
    265.     if s:lu != 0  
    266.         let s:update_str = matchstr(getline(s:lu), s:regexp)  
    267.         call setline(s:lu, s:update_str . strftime("%Y-%m-%d %H:%M:%S", localtime()))  
    268.         call setpos(".", s:original_pos)  
    269.     endif  
    270. endfunction  
    271. autocmd BufWritePost *.{h,hpp,c,cpp} call AutoUpdateTheLastUpdateInfo()  
    272. autocmd BufNewFile *.{h,hpp,c,cpp} exec 'call append(0, "\/\/ Last Update:" . strftime("%Y-%m-%d %H:%M:%S", localtime()))'  


    已经放到github上了地址是,以后将不再更新此贴,最新的可到git上查看

    https://github.com/tczengming/myvim/

    希望能给大家做一个参考。插件用bundle (也有人叫vundle)管理的,推荐大家使用bundle,插件安装升级很方便

    只要一个vimrc

    先安装bundle

    git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

    然后可下载我的.vimrc替换你的.vimrc

    git clone https://github.com/tczengming/myvim.git      

    下载后用myvim/myvimrc替换你的.vimrc (可自行修改其内容)

    然后在vim中执行

    BundleInstall!    就可以自动地更新安装插件,不用再手动去网上一个个下最新包了。
    缷载插件  :BundleClean

    carlhuda/janus

    Janus: Vim Distribution

    This is a distribution of plug-ins and mappings for Vim, Gvim and MacVim.

    It is designed to provide minimal working environment using the most popular plug-ins and the most common mappings.

    The distribution is completely customisable using a ~/.vimrc.before and ~/.vimrc.after Vim RC files.

  • 相关阅读:
    Spring 进行junit单元测试时,出现method ‘initializationError’ 错误
    反射注解
    Maven
    spring 和 spingmvc 和 mybatis 的集成应用
    SpringMVC:文件上传,文件下载,SpringMVC的拦截器,poi组件导出excel文件
    SpringMVC:SpringMVC执行流程和原理,RESTful风格支持,请求中文乱码问题, 响应传值方式, 转换JSON数据
    Spring和MyBatis的整合
    Spring的事务管理
    Spring:AOP, 面向切面编程,JDK的动态代理,CGLIB代理,Spring的AOP技术(底层就是JDK动态代理和CGLIB代理技术)
    Spring注解配置:@Component,@Controller,@Service,@Repository,@Scope,@Autowired,@Qualifier,@Resource@Value
  • 原文地址:https://www.cnblogs.com/lexus/p/2754072.html
Copyright © 2011-2022 走看看