VIM配置

记录一下自己的VIM C++开发配置:

set nocompatible

filetype on

 

set encoding=utf-8

set backspace=indent,eol,start

 

"set smartindent

set cindent

" t0:  函数返回类型声明不缩进

" g0:  C++ "public:" 等声明缩进一个字符

" h1:  C++ "public:" 等声明后面的语句缩进一个字符

" N-s: C++ namespace 里不缩进

" j1:  合理的缩进 Java 或 C++ 的匿名函数,应该也适用于 JS

set cinoptions=t0,g1,h1,N-s,j1

 

set smarttab

set expandtab | set tabstop=4 | set shiftwidth=4 | set softtabstop=4

au FileType c,cpp

   \ set expandtab | set tabstop=2 | set shiftwidth=2 | set softtabstop=2

au FileType make set noexpandtab | set tabstop=8 | set shiftwidth=8

 

au FileType c,cpp,python,vim set textwidth=80 | set colorcolumn=81

 

" show command

set showcmd

set scrolloff=7

set wildmenu

set wildmode="list:longest"

set ruler

" 命令行高度为两行

set cmdheight=2

 

" show line number

set number

 

" See [http://vim.wikia.com/wiki/Highlight_unwanted_spaces]

" - highlight trailing whitespace in red

" - have this highlighting not appear whilst you are typing in insert mode

" - have the highlighting of whitespace apply when you open new buffers

highlight ExtraWhitespace ctermbg=red guibg=red

match ExtraWhitespace /\s\+$/

autocmd BufWinEnter * match ExtraWhitespace /\s\+$/

autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/

autocmd InsertLeave * match ExtraWhitespace /\s\+$/

autocmd BufWinLeave * call clearmatches() " for performance

 

" highlight current line

set cursorline

 

" highlight search result

set incsearch

set hlsearch

map <silent> <leader><CR> :nohlsearch<CR>

 

" Yggdroot/indentLine

let g:indentLine_noConcealCursor = 1

let g:indentLine_color_term = 0

let g:indentLine_char = '|'

 

" EasyAlign

" Start interactive EasyAlign in visual mode (e.g. vipga)

xmap ga <Plug>(EasyAlign)

" Start interactive EasyAlign for a motion/text object (e.g. gaip)

nmap ga <Plug>(EasyAlign)

 

" paste toggle

set pastetoggle=<F3>

 

" NERDTree config

map <F7> :NERDTreeToggle<CR>

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") &&b:NERDTreeType == "primary") | q | endif

" ctrl + w + h    光标 focus 左侧树形目录

" ctrl + w + l    光标 focus 右侧文件显示窗口

" ctrl + w + w    光标自动在左右侧窗口切换 #!!!

" ctrl + w + r    移动当前窗口的布局位置

 

" tagbar

map <F9> :TagbarToggle<CR>

let g:tagbar_right=1

let g:tagbar_width=30

 

" python syntax

let python_highlight_all = 1

 

" vim-plug

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

Plug 'morhetz/gruvbox'

Plug 'vim-airline/vim-airline'

Plug 'Yggdroot/indentLine'

Plug 'junegunn/vim-easy-align'

Plug 'scrooloose/nerdtree'

Plug 'Valloric/YouCompleteMe'

Plug 'Raimondi/delimitMate'

Plug 'majutsushi/tagbar'

Plug 'justinmk/vim-syntax-extra'

Plug 'octol/vim-cpp-enhanced-highlight'

Plug 'hdima/python-syntax'

Plug 'w0rp/ale'

call plug#end()

 

" ycm

let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py'

let g:ycm_seed_identifiers_with_syntax=1

let g:ycm_confrm_extra_conf=0

inoremap <expr> <CR>  pumvisible() ? "\<C-y>" : "\<CR>"

set completeopt=longest,menu

 

" ctags

map :!ctags -R --c++-kinds=+p --fields=+iaS --extras=+q . :TlistUpdate

imap :!ctags -R --c++-kinds=+p --fields=+iaS --extras=+q . :TlistUpdate

"set tags=tags

set tags=./.tags;,.tags

" ctrl + ]  go def

" ctrl + t  back

 

Reference:

https://segmentfault.com/a/1190000014552112

https://segmentfault.com/a/1190000014560645

 

 

posted @ 2020-06-08 22:05  Daniel.L  阅读(70)  评论(0)    收藏  举报