個人vimrc配置

  從上個暑假開始接觸vim,一會兒愛上了這個輕量的文本編輯器。目前我用vim主要是用來寫python代碼,下一步想要接觸一下LaTex和Markdown。接觸過vim的人都知道,vimrc是每一個人的心血,每一個愛折騰的人都有一個強大的vimrc。vim也正是由於插件和高度自定義化贏得愈來愈多的人的喜好。下面把本身的vimrc記錄在此,權當作個備份。php

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
相關文章
相關標籤/搜索