.vimrc配置文件备份


折腾了好多天,终于将vim配置成自己想要的样子,里面附带了一些插件都是不错的。重要的是使用vundle来管理插件,现在插件都是采用github来托管了,使用vundle来管理插件的话,只需要带着这个.vimrc文件,随便换个电脑,很轻松地就将vim配置成自己熟悉的样子,简直不能再爽!!!唯一比较难配置的还是youcompleteme这个插件,另外对于括号补全,引号补全等,原来使用的是:inoremap来补全的,但是还是太难用,最终找到'jiangmiao/auto-pairs'这个插件,太完美了,下面就是.vimrc文件配置:



set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
" plugin from http://vim-scripts.org/vim/scripts.html
" Git plugin not hosted on GitHub
" git repos on your local machine (i.e. when working on your own plugin)
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
Plugin 'ascenator/L9', {'name': 'newL9'}
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'scrooloose/nerdtree'
Bundle 'majutsushi/tagbar'
Bundle 'bling/vim-airline'
Bundle 'scrooloose/syntastic'
Bundle 'jiangmiao/auto-pairs'
Bundle 'tpope/vim-rails.git'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'FuzzyFinder'
Bundle 'kien/rainbow_parentheses.vim'
" scripts not on GitHub
Bundle 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" ...

filetype plugin indent on     " required
Bundle 'Valloric/YouCompleteMe'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"==========================================  
" vundle设置,需要将上面的东西放在第一行
"==========================================



"==========================================  
" 显示和字体设置  
"==========================================  
set nocompatible     " 非兼容vi模式。去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限   
set autoread          " 文件修改之后自动载入。  
set shortmess=atI       " 启动的时候不显示那个援助索马里儿童的提示
syntax on " 自动语法高亮
set number " 显示行号
set cursorline " 突出显示当前行
set ruler " 打开状态栏标尺
set tabstop=4 " 设定 tab 长度为 4
set shiftwidth=4 " 统一缩进为4
set softtabstop=4 " 统一缩进为4
filetype plugin indent on " 开启插件
set ignorecase smartcase " 搜索时忽略大小写,但在有一个或以上大写字母时仍保持对大小写敏感
set incsearch " 输入搜索内容时就显示搜索结果
set hlsearch " 搜索时高亮显示被找到的文本
set magic " 设置魔术
set clipboard+=unnamed "共享剪贴板
set nobackup "从不备份
set noswapfile "禁止生成临时文件
set showmatch " 高亮显示匹配的括号
set mouse=a   " Enable mouse usage (all modes)"使用鼠标



"==========================================  
" ctags 配置  
"==========================================
map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . :TlistUpdate
imap :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . :TlistUpdate
set tags=tags
set tags+=./tags "add current directory's generated tags file



"==========================================  
" 新建文件注释补全  
"==========================================
"新建.c,.h,.sh,.java文件,自动插入文件头
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头
func SetTitle()
    "如果文件类型为.sh文件
    if &filetype == 'sh'
        call setline(1,"\#########################################################################")
        call append(line("."), "\# File Name: ".expand("%"))
        call append(line(".")+1, "\# Author: ZER0")
        call append(line(".")+2, "\# mail: 471685488@qq.com")
        call append(line(".")+3, "\# Created Time: ".strftime("%c"))
        call append(line(".")+4, "\#########################################################################")
        call append(line(".")+5, "\#!/bin/bash")
        call append(line(".")+6, "")
    else
        call setline(1, "/*************************************************************************")
        call append(line("."), "    > File Name: ".expand("%"))
        call append(line(".")+1, "    > Author: ZER0")
        call append(line(".")+2, "    > Mail: 471685488@qq.com")
        call append(line(".")+3, "    > Created Time: ".strftime("%c"))
        call append(line(".")+4, " ************************************************************************/")
        call append(line(".")+5, "")
    endif
    if &filetype == 'cpp'
        call append(line(".")+6, "#include<iostream>")
        call append(line(".")+7, "using namespace std;")
        call append(line(".")+8, "")
    endif
    if &filetype == 'c'
        call append(line(".")+6, "#include<stdio.h>")
        call append(line(".")+7, "")
    endif
    "新建文件后,自动定位到文件末尾
    autocmd BufNewFile * normal G
endfunc




"==========================================  
" NERDTree配置  
"==========================================
let NERDTreeWinPos='left' "在左边显示NERDTree"
let NERDTreeWinSize=20 "设置窗口大小为20"
let NERDTreeChDirMode=1
autocmd StdinReadPre * let s:std_in=1
autocmd vimenter * NERDTree "设置自动启动NERDTree"
wincmd w
autocmd VimEnter * wincmd w "这两行是设置启动NERDTree后光标焦点自动在右侧文件中"
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
map <F2> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"如果NERDTree是最后一个窗口的话自动关闭"



"==========================================  
" tagbar配置  
"==========================================
let g:tagbar_ctags_bin='ctags'            "ctags程序的路径
let g:tagbar_width=30                    "窗口宽度的设置
map <F3> :Tagbar<CR>
let g:tagbar_autofocus = 1 " 启动时自动focus
autocmd BufReadPost *.cpp,*.c,*.h,*.hpp,*.cc,*.cxx call tagbar#autoopen()     "如果是c语言的程序的话,tagbar自动开启




"==========================================  
" syntastic设置
"==========================================  
let g:syntastic_error_symbol='>>'
let g:syntastic_warning_symbol='>'
let g:syntastic_check_on_open=1
let g:syntastic_check_on_wq=0
let g:syntastic_enable_highlighting=1
let g:syntastic_python_checkers=['pyflakes'] " 使用pyflakes,速度比pylint快
let g:syntastic_javascript_checkers = ['jsl', 'jshint']
let g:syntastic_html_checkers=['tidy', 'jshint']
" 修改高亮的背景色, 适应主题
highlight SyntasticErrorSign guifg=white guibg=black

 " to see error location list
let g:syntastic_always_populate_loc_list = 0
let g:syntastic_auto_loc_list = 0
let g:syntastic_loc_list_height = 5
function! ToggleErrors()
    let old_last_winnr = winnr('$')
    lclose
    if old_last_winnr == winnr('$')
    " Nothing was closed, open syntastic error location panel
        Errors
   endif
endfunction
nnoremap <Leader>s :call ToggleErrors()<cr>
   " nnoremap <Leader>sn :lnext<cr>
   " nnoremap <Leader>sp :lprevious<cr>



"==========================================  
" rainbow_parentheses.vim设置
"==========================================  
let g:rbpt_colorpairs = [
    \ ['brown',       'RoyalBlue3'],
    \ ['Darkblue',    'SeaGreen3'],
    \ ['darkgray',    'DarkOrchid3'],
    \ ['darkgreen',   'firebrick3'],
    \ ['darkcyan',    'RoyalBlue3'],
    \ ['darkred',     'SeaGreen3'],
    \ ['darkmagenta', 'DarkOrchid3'],
    \ ['brown',       'firebrick3'],
    \ ['gray',        'RoyalBlue3'],
    \ ['darkmagenta', 'DarkOrchid3'],
    \ ['Darkblue',    'firebrick3'],
    \ ['darkgreen',   'RoyalBlue3'],
    \ ['darkcyan',    'SeaGreen3'],
    \ ['darkred',     'DarkOrchid3'],
    \ ['red',         'firebrick3'],
    \ ]

" 不加入这行, 防止黑色括号出现, 很难识别
" " \ ['black',       'SeaGreen3'],
"
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces



"==========================================  
" vim-airline设置
"==========================================  
set nocompatible
set laststatus=2
set t_Co=256
let g:Powerline_symbols='unicode'
set encoding=utf-8

if !exists('g:airline_symbols')
    let g:airline_symbols = {}
endif
let g:airline_left_sep = '▶'
let g:airline_left_alt_sep = '❯'
let g:airline_right_sep = '◀'
let g:airline_right_alt_sep = '❮'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
" 关闭状态显示空白符号计数
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#whitespace#symbol = '!'

" 是否打开tabline
" let g:airline#extensions#tabline#enabled = 1
" let g:airline#extensions#tabline#buffer_nr_show = 1




"==========================================  
" youcompleteme设置
"==========================================  
set completeopt=longest,menu "让Vim的补全菜单行为与一般IDE一致(参考VimTip1228)
autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口
inoremap <expr> <CR>       pumvisible() ? "\<C-y>" : "\<CR>" "回车即选中当前项
"上下左右键的行为 会显示其他信息
inoremap <expr> <Down>     pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up>       pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
inoremap <expr> <PageUp>   pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"

"youcompleteme  默认tab  s-tab 和自动补全冲突
"let g:ycm_key_list_select_completion=['<c-n>']
let g:ycm_key_list_select_completion = ['<Down>']
"let g:ycm_key_list_previous_completion=['<c-p>']
let g:ycm_key_list_previous_completion = ['<Up>']
let g:ycm_confirm_extra_conf=0 "关闭加载.ycm_extra_conf.py提示

let g:ycm_collect_identifiers_from_tags_files=1    " 开启 YCM 基于标签引擎
let g:ycm_min_num_of_chars_for_completion=2    "从第2个键入字符就开始罗列匹配项
let g:ycm_cache_omnifunc=0    " 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_seed_identifiers_with_syntax=1    " 语法关键字补全
nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>    "force recomile with syntastic
"nnoremap <leader>lo :lopen<CR>    "open locationlist
"nnoremap <leader>lc :lclose<CR>    "close locationlist
inoremap <leader><leader> <C-x><C-o> "在注释输入中也能补全
let g:ycm_complete_in_comments = 1 "在字符串输入中也能补全
let g:ycm_complete_in_strings = 1 "注释和字符串中的文字也会被收入补全
let g:ycm_collect_identifiers_from_comments_and_strings = 0
let g:ycm_show_diagnostics_ui = 0 " 关闭ycm的syntastic

nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> "跳转到定义处





阅读(233) | 评论(0) | 转发(0) |
评论热议
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是vim的.vimrc配置文件中可以设置的一些常见配置项: 1. 设置缩进 set expandtab " 将tab键转换为空格 set tabstop=4 " 设置tab宽度为4个空格 set shiftwidth=4 " 自动缩进时,每次缩进宽度为4个空格 2. 设置行号 set number " 显示行号 3. 设置高亮 syntax on " 开启语法高亮 4. 设置鼠标 set mouse=a " 开启鼠标支持 5. 设置搜索 set hlsearch " 开启搜索高亮 set ignorecase " 搜索时忽略大小写 6. 设置自动补全 set completeopt=menu,preview,longest " 自动补全设置 7. 设置配色方案 colorscheme [scheme_name] " 设置配色方案 8. 设置字体 set guifont=Monaco:h12 " 设置字体 9. 设置自动保存 set autowrite " 自动保存 10. 设置自动换行 set wrap " 自动换行 11. 设置备份 set backup " 生成备份文件 12. 设置文件编码 set encoding=utf-8 " 设置文件编码 13. 设置文件格式 set fileformat=unix " 设置文件格式 14. 设置历史记录 set history=1000 " 设置历史记录数量 15. 设置快捷键 map [command] [shortcut] " 设置快捷键 16. 设置标签页 set showtabline=2 " 显示标签页 17. 设置缩写 iab [abbrev] [full_text] " 设置缩写 18. 设置自动补全 set completeopt=menu,preview,longest " 自动补全设置 19. 设置括号自动补全 inoremap ( ()<Left> " 括号自动补全设置 20. 设置自动缩进 set smartindent " 智能缩进 21. 设置行末空格高亮 highlight ExtraWhitespace ctermbg=red guibg=red match ExtraWhitespace /\s\+$/ autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ 22. 设置文件类型 autocmd BufRead,BufNewFile *.md set filetype=markdown " 设置文件类型为markdown 23. 设置打开文件的默认目录 cd /path/to/dir " 设置打开文件的默认目录 24. 设置可视化模式 set visualbell " 可视化模式开启 25. 设置搜索高亮 set hlsearch " 搜索高亮 26. 设置自动缩进 set autoindent " 智能缩进 27. 设置制表符 set tabstop=4 " 设置制表符宽度 28. 设置缩进宽度 set shiftwidth=4 " 设置缩进宽度 29. 设置自动保存 set autowrite " 自动保存 30. 设置可视化模式 set visualbell " 可视化模式开启 31. 设置折叠 set foldmethod=syntax " 语法折叠 32. 设置语言环境 set langmenu=en_US.UTF-8 " 设置语言环境 33. 设置命令行历史 set history=1000 " 设置命令行历史 34. 设置行号 set number " 显示行号 35. 设置自动补全 set completeopt=menu,preview,longest " 自动补全设置 36. 设置括号匹配 set showmatch " 显示括号匹配 37. 设置缓冲区 set hidden " 隐藏缓冲区 38. 设置会话 set sessionoptions=blank,buffers,curdir,folds,help,options,tabpages,winsize " 设置会话 39. 设置鼠标支持 set mouse=a " 开启鼠标支持 40. 设置颜色 set t_Co=256 " 256种颜色支持 41. 设置标签页 set showtabline=2 " 显示标签页 42. 设置缓存 set directory=~/.vim/tmp " 缓存目录 43. 设置备份 set backupdir=~/.vim/backup " 备份目录 44. 设置缩写 iab [abbrev] [full_text] " 设置缩写 45. 设置字体 set guifont=Monaco:h12 " 设置字体 46. 设置文件编码 set encoding=utf-8 " 设置文件编码 47. 设置文件格式 set fileformat=unix " 设置文件格式 48. 设置快捷键 map [command] [shortcut] " 设置快捷键 49. 设置显示行末空格 highlight ExtraWhitespace ctermbg=red guibg=red match ExtraWhitespace /\s\+$/ autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ 50. 设置文件类型 autocmd BufRead,BufNewFile *.md set filetype=markdown " 设置文件类型为markdown

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值