1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 通用设置 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let mapleader = "," " 定义<leader>键 set nocompatible " 设置不兼容原始vi模式 filetype on " 设置开启文件类型侦测 filetype plugin on " 设置加载对应文件类型的插件 set noeb " 关闭错误的提示 syntax enable " 开启语法高亮功能 syntax on " 自动语法高亮 set t_Co=256 " 开启256色支持 set cmdheight=2 " 设置命令行的高度 set showcmd " select模式下显示选中的行数 set ruler " 总是显示光标位置 set laststatus=2 " 总是显示状态栏 set number " 开启行号显示 set cursorline " 高亮显示当前行 set whichwrap+=<,>,h,l " 设置光标键跨行 set ttimeoutlen=0 " 设置<ESC>键响应时间 set virtualedit=block,onemore " 允许光标出现在最后一个字符的后面
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 代码缩进和排版 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set autoindent " 设置自动缩进 set cindent " 设置使用C/C++语言的自动缩进方式 set cinoptions=g0,:0,N-s,(0 " 设置C/C++语言的具体缩进方式 set smartindent " 智能的选择对其方式 filetype indent on " 自适应不同语言的智能缩进 set expandtab " 将制表符扩展为空格 set tabstop=4 " 设置编辑时制表符占用空格数 set shiftwidth=4 " 设置格式化时制表符占用空格数 set softtabstop=4 " 设置4个空格为制表符 set smarttab " 在行和段开始处使用制表符 set nowrap " 禁止折行 set backspace=2 " 使用回车键正常处理indent,eol,start等 set sidescroll=10 " 设置向右滚动字符数 set nofoldenable " 禁用折叠代码
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 代码补全 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set wildmenu " vim自身命名行模式智能补全 set completeopt-=preview " 补全时不显示窗口,只显示补全列表
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 搜索设置 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set hlsearch " 高亮显示搜索结果 set incsearch " 开启实时搜索功能 set ignorecase " 搜索时大小写不敏感
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 缓存设置 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set nobackup " 设置不备份 set noswapfile " 禁止生成临时文件 set autoread " 文件在vim之外修改过,自动重新读入 set autowrite " 设置自动保存 set confirm " 在处理未保存或只读文件的时候,弹出确认
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 编码设置 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set langmenu=zh_CN.UTF-8 set helplang=cn set termencoding=utf-8 set encoding=utf8 set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " gvim/macvim设置 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if has("gui_running") set guifont=Droid\ Sans\ Mono\ Nerd\ Font\ Complete:h18 " 设置字体 set guioptions-=m " 隐藏菜单栏 set guioptions-=T " 隐藏工具栏 set guioptions-=L " 隐藏左侧滚动条 set guioptions-=r " 隐藏右侧滚动条 set guioptions-=b " 隐藏底部滚动条 set showtabline=0 " 隐藏Tab栏 set guicursor=n-v-c:ver5 " 设置光标为竖线 endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 插件列表 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" call plug#begin('~/.vim/plugged')
Plug 'chxuan/cpp-mode' Plug 'chxuan/vim-edit' Plug 'chxuan/change-colorscheme' Plug 'chxuan/prepare-code' Plug 'mhinz/vim-startify' Plug 'chxuan/tagbar' Plug 'Valloric/YouCompleteMe' Plug 'Yggdroot/LeaderF' Plug 'mileszs/ack.vim' Plug 'easymotion/vim-easymotion' Plug 'haya14busa/incsearch.vim' Plug 'iamcco/mathjax-support-for-mkdp' Plug 'iamcco/markdown-preview.vim' Plug 'jiangmiao/auto-pairs' Plug 'scrooloose/nerdtree' Plug 'tiagofumo/vim-nerdtree-syntax-highlight' Plug 'Xuyuanp/nerdtree-git-plugin' Plug 'godlygeek/tabular' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-surround' Plug 'tpope/vim-commentary' Plug 'tpope/vim-repeat' Plug 'tpope/vim-endwise' Plug 'octol/vim-cpp-enhanced-highlight' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'ryanoasis/vim-devicons' Plug 'junegunn/vim-slash' Plug 'junegunn/gv.vim' Plug 'kana/vim-textobj-user' Plug 'kana/vim-textobj-indent' Plug 'kana/vim-textobj-syntax' Plug 'kana/vim-textobj-function' Plug 'sgur/vim-textobj-parameter' Plug 'Shougo/echodoc.vim' Plug 'terryma/vim-smooth-scroll' Plug 'rhysd/clever-f.vim' Plug 'rhysd/github-complete.vim' Plug 'vim-scripts/indentpython.vim'
call plug#end()
" load vim default plugin runtime macros/matchit.vim
" 编辑vimrc文件 nnoremap <leader>e :edit $MYVIMRC<cr>
" 查看vimplus的help文件 nnoremap <leader>h :edit ~/.vimplus/help.md<cr>
" 打开当前光标所在单词的vim帮助文档 nnoremap <leader>H :execute ":help " . expand("<cword>")<cr>
" 重新加载vimrc文件 nnoremap <leader>s :source $MYVIMRC<cr>
" 安装、更新、删除插件 nnoremap <leader><leader>i :PlugInstall<cr> nnoremap <leader><leader>u :PlugUpdate<cr> nnoremap <leader><leader>c :PlugClean<cr>
" 打开文件自动定位到最后编辑的位置 autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g'\"" | endif
" 主题 set background=dark let g:onedark_termcolors=256 colorscheme onedark
" airline let g:airline_theme="onedark" let g:airline_powerline_fonts = 1 let g:airline 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 = ''
" cpp-mode nnoremap <leader>y :CopyCode<cr> nnoremap <leader>p :PasteCode<cr> nnoremap <leader>U :GoToFunImpl<cr> nnoremap <silent> <leader>a :Switch<cr> nnoremap <leader><leader>fp :FormatFunParam<cr> nnoremap <leader><leader>if :FormatIf<cr>
" change-colorscheme nnoremap <silent> <F9> :PreviousColorScheme<cr> inoremap <silent> <F9> <esc> :PreviousColorScheme<cr> nnoremap <silent> <F10> :NextColorScheme<cr> inoremap <silent> <F10> <esc> :NextColorScheme<cr> nnoremap <silent> <F11> :RandomColorScheme<cr> inoremap <silent> <F11> <esc> :RandomColorScheme<cr> nnoremap <silent> <F12> :ShowColorScheme<cr> inoremap <silent> <F12> <esc> :ShowColorScheme<cr>
" prepare-code let g:prepare_code_plugin_path = expand($HOME . "/.vim/plugged/prepare-code")
" vim-edit nnoremap Y :CopyText<cr> nnoremap D :DeleteText<cr> nnoremap C :ChangeText<cr> nnoremap <leader>r :ReplaceTo<space>
" nerdtree nnoremap <silent> <leader>n :NERDTreeToggle<cr> inoremap <silent> <leader>n <esc> :NERDTreeToggle<cr> let g:NERDTreeFileExtensionHighlightFullName = 1 let g:NERDTreeExactMatchHighlightFullName = 1 let g:NERDTreePatternMatchHighlightFullName = 1 let g:NERDTreeHighlightFolders = 1 let g:NERDTreeHighlightFoldersFullName = 1 let g:NERDTreeDirArrowExpandable='▷' let g:NERDTreeDirArrowCollapsible='▼'
" YCM let g:ycm_confirm_extra_conf = 0 let g:ycm_error_symbol = '✗' let g:ycm_warning_symbol = '✹' let g:ycm_seed_identifiers_with_syntax = 1 let g:ycm_complete_in_comments = 1 let g:ycm_complete_in_strings = 1 let g:ycm_server_python_interpreter = '/usr/bin/python' let g:ycm_python_binary_path = 'python' nnoremap <leader>u :YcmCompleter GoToDeclaration<cr> " 已经使用cpp-mode插件提供的转到函数实现的功能 " nnoremap <leader>i :YcmCompleter GoToDefinition<cr> nnoremap <leader>o :YcmCompleter GoToInclude<cr> nnoremap <leader>ff :YcmCompleter FixIt<cr> nmap <F5> :YcmDiags<cr>
" ctags set tags+=/usr/include/tags set tags+=~/.vim/systags set tags+=~/.vim/x86_64-linux-gnu-systags let g:ycm_collect_identifiers_from_tags_files = 1 let g:ycm_semantic_triggers = { \ 'c' : ['->', '.','re![_a-zA-z0-9]'], \ 'objc' : ['->', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s', \ 're!\[.*\]\s'], \ 'ocaml' : ['.', '#'], \ 'cpp,objcpp' : ['->', '.', '::','re![_a-zA-Z0-9]'], \ 'perl' : ['->'], \ 'php' : ['->', '::'], \ 'cs,java,javascript,typescript,d,python,perl6,scala,vb,elixir,go' : ['.'], \ 'ruby' : ['.', '::'], \ 'lua' : ['.', ':'], \ 'erlang' : [':'], \ } let g:ycm_semantic_triggers.c = ['->', '.', ' ', '(', '[', '&',']']
" tagbar let g:tagbar_width = 30 nnoremap <silent> <leader>t :TagbarToggle<cr> inoremap <silent> <leader>t <esc> :TagbarToggle<cr>
" incsearch.vim map / <Plug>(incsearch-forward) map ? <Plug>(incsearch-backward) map g/ <Plug>(incsearch-stay)
" markdown let g:mkdp_auto_start = 0 " Set to 1, Vim will open the preview window on entering the Markdown " buffer.
let g:mkdp_auto_open = 1 " Set to 1, Vim will automatically open the preview window when you edit a " Markdown file.
let g:mkdp_auto_close = 1 " Set to 1, Vim will automatically close the current preview window when " switching from one Markdown buffer to another.
let g:mkdp_refresh_slow = 0 " Set to 1, Vim will just refresh Markdown when saving the buffer or " leaving from insert mode. With default 0, it will automatically refresh " Markdown as you edit or move the cursor.
let g:mkdp_command_for_global = 0 " Set to 1, the MarkdownPreview command can be used for all files, " by default it can only be used in Markdown files. let g:mkdp_open_to_the_world = 0 " Set to 1, the preview server will be available to others in your network. " By default, the server only listens on localhost (127.0.0.1).
nmap <silent> <F7> <Plug>MarkdownPreview imap <silent> <F7> <Plug>MarkdownPreview nmap <silent> <F8> <Plug>StopMarkdownPreview imap <silent> <F8> <Plug>StopMarkdownPreview
" vim-easymotion let g:EasyMotion_smartcase = 1 map <leader>w <Plug>(easymotion-bd-w) nmap <leader>w <Plug>(easymotion-overwin-w)
" nerdtree-git-plugin let g:NERDTreeIndicatorMapCustom = { \ "Modified" : "✹", \ "Staged" : "✚", \ "Untracked" : "✭", \ "Renamed" : "➜", \ "Unmerged" : "═", \ "Deleted" : "✖", \ "Dirty" : "✗", \ "Clean" : "✔︎", \ 'Ignored' : '☒', \ "Unknown" : "?" \ }
" LeaderF nnoremap <leader>f :LeaderfFile ~<cr> let g:Lf_WildIgnore = { \ 'dir': ['.svn','.git','.hg','.vscode','.wine','.deepinwine','.oh-my-zsh'], \ 'file': ['*.sw?','~$*','*.bak','*.exe','*.o','*.so','*.py[co]'] \} let g:Lf_UseCache = 0
" ack nnoremap <leader>F :Ack!<space>
" echodoc.vim let g:echodoc_enable_at_startup = 1
" tabular nnoremap <leader>l :Tab /\|<cr> nnoremap <leader>= :Tab /=<cr>
" vim-smooth-scroll noremap <silent> <c-u> :call smooth_scroll noremap <silent> <c-d> :call smooth_scroll noremap <silent> <c-b> :call smooth_scroll noremap <silent> <c-f> :call smooth_scroll
" gv nnoremap <leader>g :GV<cr> nnoremap <leader>G :GV!<cr> nnoremap <leader>gg :GV?<cr>
|