我的vimrc配置

  从上个暑假开始接触vim,一下子爱上了这个轻量的文本编辑器。目前我用vim主要是用来写python代码,下一步想要接触一下LaTex和Markdown。接触过vim的人都知道,vimrc是每个人的心血,每个爱折腾的人都有一个强大的vimrc。vim也正是因为插件和高度自定义化赢得越来越多的人的喜爱。下面把自己的vimrc记录在此,权当做个备份。

syntax on                  " Enable syntax highlighting.
filetype plugin indent on  " Enable file type based indentation.

set autoindent             " Respect indentation when starting a new line.
set expandtab              " Expand tabs to spaces. Essential in Python.
set tabstop=4              " Number of spaces tab is counted for.
set shiftwidth=4           " Number of spaces to use for autoindent.
set mouse=a               " 可以使用鼠标
set backspace=2            " Fix backspace behavior on most terminals.



" Fast split navigation with <Ctrl> + hjkl.
noremap <c-h> <c-w><c-h>
noremap <c-j> <c-w><c-j>
noremap <c-k> <c-w><c-k>
noremap <c-l> <c-w><c-l>

set foldmethod=indent "display all files as folded by default
autocmd BufRead * normal zR

set wildmenu                    " Enable enhanced tab autocomplete.
set wildmode=list:longest,full  " Complete till longest string,
								" then open the wildmenu.

set number "添加行号
set hlsearch "高亮查找结果
set clipboard=unnamed,unnamedplus  " Copy into system (*) register.


"Plug-ins config
packloadall           " Load all plugins.
silent! helptags ALL  " Load help files for all plugins.
let g:plug_timeout = 300 " Increase vim-plug timeout for YouCompleteMe.
" Manage plugins with vim-plug.

call plug#begin('~/.vim/plugged')

Plug 'Valloric/YouCompleteMe'   "自动补全插件
Plug 'tpope/vim-vinegar'    "横杠键更强大
Plug 'ctrlpvim/ctrlp.vim'   "搜索
"Plug 'sjl/gundo.vim'   "undo树
Plug 'tpope/vim-fugitive'  "在vim中进行git操作
Plug 'vim-scripts/ScrollColors'     "主题配置小帮手
Plug 'vim-airline/vim-airline'      "好看的底栏
Plug 'jiangmiao/auto-pairs'     "分号括号自动补全
Plug 'scrooloose/nerdtree'      "文件浏览
Plug 'vim-syntastic/syntastic'  "自动检查语法
Plug 'KeitaNakamura/neodark.vim'    "美妙的主题
"Plug 'Yggdroot/indentLine'
Plug 'haya14busa/incsearch.vim'     "增强版search
Plug 'scrooloose/nerdcommenter'     "快速注释插件

call plug#end()

"incsearch配置
map /  <Plug>(incsearch-forward)
map ?  <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)


set belloff=all " 所有事件下(包括错按esc,错按backspace)不发出声音
noremap <leader>] :YcmCompleter GoTo<cr> " 转到定义

#let g:airline#extensions#tabline#enabled = 1

" Always display status line (or what's the purpose of having powerline?)
"set laststatus=2
"let g:airline_powerline_fonts = 1   " 使用powerline打过补丁的字体
"let g:Powerline_symbols='fancy'

" Load powerline.
"python3 from powerline.vim import setup as powerline_setup
"python3 powerline_setup()
"python3 del powerline_setup

command! Bd :bp | :sp | :bn | :bd  " Close buffer without closing window.


nnoremap <silent> <leader>. :cd %:p:h<CR>   "自动cd
nnoremap <silent> <leader>q :SyntasticToggleMode<CR>    "调节Syntastic为积极或者消极模式 
set completeopt-=preview   "自动补全不会触发preview窗口

map <C-n> :NERDTreeToggle<CR>   "打开NERDTree的快捷键
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif   "调节NERDTree在没有buffer时是否关闭

"NERDTress File highlighting
function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
 exec 'autocmd filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
 exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^s+.*'. a:extension .'$#'
endfunction

call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#222f37')
call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#222f37')
call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#222f37')
call NERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#222f37')
call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#222f37')
call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#222f37')
call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#222f37')
call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#222f37')
call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#222f37')
call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#222f37')
call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#222f37')
call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#222f37')
call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#222f37')

"去点丑陋的侧边滚动轴
set guioptions-=r 
set guioptions-=L
set guioptions-=b

cd /Users/apple/Desktop/freework   "更改vim运行默认路径
set guifont=SourceCodeVariable-Roman:h20    "更改vim默认字体


" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1

" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1

" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'

" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1

" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }

" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1

" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1

" Enable NERDCommenterToggle to check all selected lines is commented or not 
let g:NERDToggleCheckAllLines = 1
原文地址:https://www.cnblogs.com/chester-cs/p/11633663.html