"" ------------------------------------------Vundle插件配置开始----------------------------------------
set nocompatible
filetype off
" 你在此设置Vundle插件运行时路径
set rtp+=~/.vim/bundle/Vundle.vim
" vundle初始化
call vundle#begin()
" 这应该始终是第一个
Plugin 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree'
""-------------------------------------------nerdtree插件配置开始--------------------------------------
" NerdTree才插件的配置信息
""将F2设置为开关NERDTree的快捷键
map <f2> :NERDTreeToggle<cr>
""修改树的显示图标
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
""窗口位置
let g:NERDTreeWinPos='left'
""窗口尺寸
let g:NERDTreeSize=30
""窗口是否显示行号
let g:NERDTreeShowLineNumbers=1
""不显示隐藏文件
let g:NERDTreeHidden=0
""-------------------------------------------nerdtree插件配置结束--------------------------------------
Plugin 'taglist.vim'
""-------------------------------------------taglist插件配置开始---------------------------------------
"ctags 配置:F3快捷键显示程序中的各种tags,包括变量和函数等。
map <F3> :TlistToggle<CR>
let Tlist_Use_Right_Window=1
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_WinWidt=35
""-------------------------------------------taglist插件配置结束---------------------------------------
Plugin 'vim-airline/vim-airline'
""-------------------------------------------airline插件配置开始---------------------------------------
"vim-airline配置:优化vim界面"
"let g:airline#extensions#tabline#enabled = 1
" airline设置
" 显示颜色
set t_Co=256
set laststatus=2
" 使用powerline打过补丁的字体
let g:airline_powerline_fonts = 1
" 开启tabline
let g:airline#extensions#tabline#enabled = 1
" tabline中当前buffer两端的分隔字符
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
" 映射切换buffer的键位
nnoremap [b :bp<CR>
nnoremap ]b :bn<CR>
" 映射<leader>num到num buffer
map <leader>1 :b 1<CR>
map <leader>2 :b 2<CR>
map <leader>3 :b 3<CR>
map <leader>4 :b 4<CR>
map <leader>5 :b 5<CR>
map <leader>6 :b 6<CR>
map <leader>7 :b 7<CR>
map <leader>8 :b 8<CR>
map <leader>9 :b 9<CR>
""-------------------------------------------airline插件配置结束---------------------------------------
"Plugin 'Valloric/YouCompleteMe'
"""----------------------------------------YouCompleteMe插件配置开始-----------------------------------
""set runtimepath+=~/.vim/bundle/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 = ['<c-n>', '<Down>'] " 映射按键,没有这个会拦截掉tab, 导致其他插件的tab不能用.
"let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
"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 " 禁用语法检查
"inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" " 回车即选中当前项
"nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳转到定义处
"let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项
"-----------------------------------------YouCompleteMe插件配置结束-----------------------------------
""----------------------------------------每个插件都应该在这一行之前------------------------------------------------------
call vundle#end() " required
set hlsearch
set backspace=2
set autoindent
set ruler
set showmode
set nu
set bg=dark
syntax on
set wildmenu
set cursorcolumn
hi cursorcolumn guibg=darkred
set cursorline
hi cursorcoline guibg=darkred
set clipboard=unnamed
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头
func SetTitle()
"如果文件类型为.sh文件
if &filetype == 'sh'
call setline(1, "##########################################################################")
call append(line("."), "# File Name: ".expand("%"))
call append(line(".")+1, "# Author: gkwfhv")
call append(line(".")+2, "# mail: 2019222013@nwnu.edu.cn")
call append(line(".")+3, "# Created Time: ".strftime("%c"))
call append(line(".")+4, "#########################################################################")
call append(line(".")+5, "#!/bin/bash")
call append(line(".")+6, "PATH=/home/zhuoyu/bin:/home/zhuoyu/.local/bin:/opt/ros/kinetic/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:")
call append(line(".")+7, "export PATH")
call append(line(".")+8, "")
else
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: gkwfhv")
call append(line(".")+2, " > Mail: 2019222013@nwnu.edu.cn ")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
endif
if &filetype == 'cpp'
call append(line(".")+6, "#include <iostream>")
call append(line(".")+7, "")
call append(line(".")+8, "using namespace std;")
call append(line(".")+9, "")
call append(line(".")+10, "int main (int argc, char **argv)")
call append(line(".")+11, "{")
call append(line(".")+12, " ")
call append(line(".")+13, " ")
call append(line(".")+14, " return 0;")
call append(line(".")+15, "}")
endif
if &filetype == 'c'
call append(line(".")+6, "#include<stdio.h>")
call append(line(".")+7, "")
endif
if &filetype == 'java'
call append(line(".")+6,"public class ".expand("%"))
call append(line(".")+7,"")
endif
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
endfunc
vim 配置(有插件)
最新推荐文章于 2024-08-09 20:04:26 发布