Vim外掛配置與vimrc


Posted by nathan2009729 on 2022-07-02

總共裝了
Vundle、tagbar、nerdtree、ale、YouCompleteMe等外掛

vimrc:

set nocompatible 
set term=ansi 
"set t_co=256 
set backspace=2 
:set nu 
:set ai 
:set cursorline 
:set bg=dark 
:set tabstop=4 
:set shiftwidth=4 
:set expandtab 
syntax on 
:inoremap ( ()<Esc>i
:inoremap " ""<Esc>i
:inoremap ' ''<Esc>i
:inoremap [ []<Esc>i
:inoremap {<CR> {<CR>}<Esc>ko
:inoremap {{ {}<ESC>i
filetype indent on
filetype plugin indent on
set completeopt=longest,menu

" Vundle manage
set nocompatible               
filetype off                   

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'
Plugin 'majutsushi/tagbar'
Plugin 'scrooloose/nerdtree'
Plugin 'w0rp/ale'
Plugin 'Valloric/YouCompleteMe'

call vundle#end()              
filetype plugin indent on

"ctags
:set tags=tags

"cscope
if has("cscope")
  set csprg=/usr/bin/cscope
  set csto=1
  set cst
  set nocsverb
  " add any database in current directory
  if filereadable("cscope.out")
    cs add cscope.out
  endif
  set csverb
endif

:set cscopequickfix=s-,c-,d-,i-,t-,e-

"Tagbar
let g:tagbar_width=25
autocmd BufReadPost *.cpp,*.c,*.h,*.cc,*.cxx call tagbar#autoopen()

" NERDTree
" Start NERDTree when Vim is started without file arguments.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif
" NERDTree other
" let NERDTreeWinSize=15
" let NERDTreeShowLineNumbers=1
" let NERDTreeAutoCenter=1
" let NERDTreeShowBookmarks=1

"ale
"self definition the picture of error and warning
let g:ale_sign_error = 'X'
let g:ale_sign_warning = 'w'
"
let g:ale_statusline_format = ['X %d', 'w %d', 'y OK']
let g:ale_echo_msg_format = '[%linter%] %code: %%s'
let g:ale_lint_on_text_changed = 'normal'
let g:ale_lint_on_insert_leave = 1
let g:ale_c_gcc_options = '-Wall -O2 -std=c99'
let g:ale_cpp_gcc_options = '-Wall -O2 -std=c++14'
let g:ale_c_cppcheck_options = ''
let g:ale_cpp_cppcheck_options = ''

"YouCompleteMe
let g:ycm_server_python_interpreter='/usr/bin/python3'
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'

YouCompleteMe(YCM) vimrc配置

let g:ycm_global_ycm_extra_conf = '/home/zhangjikai/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
let g:ycm_semantic_triggers = {}
let g:ycm_semantic_triggers.c = ['->', '.', '(', '[', '&']
let g:ycm_collect_identifiers_from_tags_files=1
let g:ycm_min_num_of_chars_for_completion=3
let g:ycm_seed_identifiers_with_syntax=1

" YouCompleteMe 功能  
" 补全功能在注释中同样有效  
let g:ycm_complete_in_comments=0
" 允许 vim 加载 .ycm_extra_conf.py 文件,不再提示  
let g:ycm_confirm_extra_conf=0
" 开启 YCM 基于标签引擎  
let g:ycm_collect_identifiers_from_tags_files=1  
" 引入 C++ 标准库tags,这个没有也没关系,只要.ycm_extra_conf.py文件中指定了正确的标准库路径  
set tags+=/data/misc/software/misc./vim/stdcpp.tags  
" YCM 集成 OmniCppComplete 补全引擎,设置其快捷键  
inoremap <leader>; <C-x><C-o>  
" 补全内容不以分割子窗口形式出现,只显示补全列表  
set completeopt-=preview  
" 从第一个键入字符就开始罗列匹配项  
let g:ycm_min_num_of_chars_for_completion=1
" 禁止缓存匹配项,每次都重新生成匹配项  
let g:ycm_cache_omnifunc=0  
" 语法关键字补全              
let g:ycm_seed_identifiers_with_syntax=1  
" 修改对C函数的补全快捷键,默认是CTRL + space,修改为ALT + ;  
let g:ycm_key_invoke_completion = '<M-;>'  
" 设置转到定义处的快捷键为ALT + G,这个功能非常赞  
nmap <M-g> :YcmCompleter GoToDefinitionElseDeclaration <C-R>=expand("<cword>")<CR><CR>  
" 设置按哪个键上屏
let g:ycm_key_list_select_completion = ['<TAB>', '<Down>', '<Enter>']

vim-buffet vimrc配置

nmap <leader>1 <Plug>BuffetSwitch(1) "反斜線1切到第一個分頁,以此類推
nmap <leader>2 <Plug>BuffetSwitch(2)
nmap <leader>3 <Plug>BuffetSwitch(3)
nmap <leader>4 <Plug>BuffetSwitch(4)
nmap <leader>5 <Plug>BuffetSwitch(5)
nmap <leader>6 <Plug>BuffetSwitch(6)
nmap <leader>7 <Plug>BuffetSwitch(7)
nmap <leader>8 <Plug>BuffetSwitch(8)
nmap <leader>9 <Plug>BuffetSwitch(9)
nmap <leader>0 <Plug>BuffetSwitch(10)

noremap <Tab> :bn<CR> "按Tab切到下一個分頁
noremap <S-Tab> :bp<CR> "按shift+Tab切到上一個分頁
noremap <Leader><Tab> :Bw<CR> "關閉分頁
noremap <Leader><S-Tab> :Bw!<CR> "強制關閉分頁
noremap <C-t> :tabnew split<CR> "新增名為split的分頁

Reference

( Ubuntu环境下 ) Vim插件管理器 Vundle 的安装
linux 中的vim的配置文件:.vimrc 在哪里?
vim 插件 通过vundle 安装 tagbar
替 Vim 安裝 Tagbar ( Install Tagbar for Vim on Mac OS X )
VIM + cscope 達到類似 source Insight 找尋 calls, symbol功能
NERDTree — 好用的 vim 樹狀檔案管理 plugin
NERDTree github
vim利器:vundle 管理器和NERDTree插件
vim實戰:外掛安裝(Vundle,NerdTree)
Vim中异步语法检查ale配置
错误提示:The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code 1.
YouCompleteMe unavailable: requires Vim compiled with Python (2.6+ or 3.3+) support
Mac安装YCM遇到YouCompleteMe unavailable: requires Vim compiled with Python (3.5.1+) support.
YouCompleteMe的安装及配置(一):使用clangd进行语义的补全
http://vim.zhangjikai.com/%E6%8F%92%E4%BB%B6/youcompleteme.html
(vim-buffet)[https://github.com/bagrat/vim-buffet]


#vim







Related Posts

CodeWars 解題心得 : RGB To Hex Conversion

CodeWars 解題心得 : RGB To Hex Conversion

VS code 段落過長怎麼辦?

VS code 段落過長怎麼辦?

滲透測試重新打底(2.3)--論Enumeration(枚舉)之NFS & SMB

滲透測試重新打底(2.3)--論Enumeration(枚舉)之NFS & SMB


Comments