个人vim配置

个人vim配置,第1张

个人vim配置

条件:

  • 安装powline软件
  • 安装vundle插件
  • 安装plug插件
  • 安装bundle插件
  • 插件得了解基本它们的基本用法(知道怎么用它们安装其他插件)

功能:

  • java自动补全、其他的基本补全
  • 高亮
  • 很好看

展示如下

~/.vimrc

set nocompatible
filetype on

set runtimepath+=~/.vim/bundle/neobundle.vim/
set runtimepath+=~/.vim/bundle/YouCompleteMe
set rtp+=~/.vim/bundle/Vundle.vim

call vundle#begin()
    Plugin 'vim-airline/vim-airline'
    Plugin 'vim-airline/vim-airline-themes'
    Plugin 'taglist.vim'
    Plugin 'The-NERD-tree'
    Plugin 'indentLine.vim'
    Plugin 'delimitMate.vim' 
call vundle#end()

call plug#begin() 
    Plug 'artur-shaik/vim-javacomplete2' 
    Plug 'preservim/nerdcommenter'
    Plug 'sheerun/vim-polyglot'
    Plug 'sbdchd/neoformat'
    Plug 'mhinz/vim-startify'
call plug#end()

" YouCompleteMe:语句补全插件
autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口"
let g:ycm_collect_identifiers_from_tags_files = 1           " 开启 YCM基于标签引擎
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释与字符串中的内容也用于补全
let g:syntastic_ignore_files=[".*\.py$"]
let g:ycm_seed_identifiers_with_syntax = 1                  " 语法关键字补全
let g:ycm_complete_in_comments = 1
let g:ycm_confirm_extra_conf = 0                            " 关闭加载.ycm_extra_conf.py提示
let g:ycm_key_list_select_completion = ['', '']  " 映射按键,没有这个会拦截掉tab, 导致其他插件的tab不能用.
let g:ycm_key_list_previous_completion = ['', '']
let g:ycm_complete_in_comments = 1                          " 在注释输入中也能补全
let g:ycm_complete_in_strings = 1                           " 在字符串输入中也能补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
let g:ycm_show_diagnostics_ui = 0                           " 禁用语法检查
let g:ycm_min_num_of_chars_for_completion=2                 " 从第2个键入字符就开始罗列匹配项 

"Java设置"
autocmd FileType java setlocal omnifunc=javacomplete#Complete
nmap  (JavaComplete-Imports-AddSmart)
imap  (JavaComplete-Imports-AddSmart)
nmap  (JavaComplete-Imports-Add)
imap  (JavaComplete-Imports-Add)
imap  (JavaComplete-Imports-AddMissing)
nmap  (JavaComplete-Imports-AddMissing)
imap  (JavaComplete-Imports-RemoveUnused)
nmap  (JavaComplete-Imports-RemoveUnused)
 
" 显示颜色
set t_Co=256
" 使用powerline打过补丁的字体
let g:airline_powerline_fonts = 0
" 开启tabline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
" tabline中未激活buffer两端的分隔字符
let g:airline#extensions#tabline#left_alt_sep = ' '
" tabline中buffer显示编号
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline_theme="luna" 

" 关闭状态显示空白符号计数
let g:airline#extensions#whitespace#enabled = 0


nnoremap [b :bp
nnoremap ]b :bn


map 1 :b 1
map 2 :b 2
map 3 :b 3
map 4 :b 4
map 5 :b 5
map 6 :b 6
map 7 :b 7
map 8 :b 8
map 9 :b 9
 
"ctags 配置:F3快捷键显示程序中的各种tags,包括变量和函数等。
map <F3> :TlistToggle<CR>
let Tlist_GainFocus_On_ToggleOpen=1
let Tlist_Use_Right_Window=1
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_File_Fold_Auto_Close=1
""let Tlist_WinWidt=10
let Tlist_Use_Horiz_Window=1
map <F2> :NERDTreeToggle<CR>
let NERDTreeWinSize=25 
 
 
 
 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""实用设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set autoread
set completeopt=preview,menu 
filetype plugin on
set clipboard=unnamed 
set nobackup
set autowrite
set magic                   " 设置魔术
set guioptions-=T           " 隐藏工具栏
set guioptions-=m           " 隐藏菜单栏
set foldcolumn=0
set foldmethod=indent 
set foldlevel=3 
set foldenable              " 开始折叠
set nocompatible
set syntax=on
set noeb
set confirm
set autoindent
set cindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab
set number
set history=1000
set nobackup
set noswapfile
set ignorecase
set hlsearch
set incsearch
set gdefault
set enc=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set langmenu=zh_CN.UTF-8
set helplang=cn
set laststatus=0
filetype on
filetype plugin on
filetype indent on
set viminfo+=!
set iskeyword+=_,$,@,%,#,-
set linespace=0
set wildmenu
set backspace=2
set whichwrap+=<,>,h,l
set mouse=a
set selection=exclusive
set report=0
set fillchars=vert:\ ,stl:\ ,stlnc:\
set showmatch
set matchtime=1
set scrolloff=3
set smartindent
 au BufRead,BufNewFile *  setfiletype txt
 
:inoremap ( ()<ESC>i
"":inoremap ) <c-r>=ClosePair(')')<CR>
"":inoremap { {<C-R>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
"":inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
function! ClosePair(char)
	if getline('.')[col('.') - 1] == a:char
		return "\"
	else
		return a:char
	endif
endfunction
filetype plugin indent on 
"打开文件类型检测, 加了这句才可以用智能补全
set completeopt=longest,menu

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/742363.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-28
下一篇 2022-04-28

发表评论

登录后才能评论

评论列表(0条)

保存