Vim配置
2019-02-22 本文已影响0人
LazyBoon
Vim
安装
$ yum -y install vim*
安装Vundle
$ cd
$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
配置.vimrc
$ cd && vim .vimrc
个人喜好常用配置
" 允许使用退格键
set backspace=2
" 语法高亮
syntax on
" 使用配色方案
colorscheme desert
" 显示行号
set nu
" 打开文件类型检测功能
filetype on
" 不同文件类型采用不同的缩进
filetype indent on
" 关闭vi模式
set nocp
" 取消vi兼容,vi键盘模式不易用
set nocompatible
" 历史命令保存行数
set history=100
" 当文件被外部改变时自动读取
set autoread
" 允许使用鼠标定位点击
set mouse=a
" 允许区域选择
set selection=exclusive
set selectmode=mouse,key
" 高亮光标所在行
set cursorline
" 取消光标闪烁
set novisualbell
" 总是显示状态行
set laststatus=2
" 状态栏显示当前执行的命令
set showcmd
" 标尺功能,显示当前贯标所在的行列
set ruler
" 设置命令行高度
set cmdheight=3
" 粘贴时保持格式
set paste
" 高亮显示匹配的括号
set showmatch
" 在搜索的时候忽略大小写
set ignorecase
" 高亮被搜索到的内容
set hlsearch
" 在搜索时,输入的词句逐字符高亮(类似firefox的搜索)
set incsearch
" 继承前一行的缩进方式,特别适用于多行注释
set autoindent
" 为C程序提供自动缩进
set smartindent
" 使用C的样式缩进
set cindent
" 制表符为4个空白
set tabstop=4
" 统一缩进为4
set softtabstop=4
set shiftwidth=4
" 取消换行
set nowrap
" 启动的时候不显示提示
"set shortmess=atI
" 光标移动到buffer的顶部和底部时保持距离,或set so=3
set scrolloff=3
" 设定默认编码
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936
" 设定字体
set guifont=Courier_New:h11:cANSI
set guifontwide=新宋体:h11:cGB2312
" 设定编码
set enc=utf-8
set fileencodings=ucs-bom,utf-8,chinese
set langmenu=zh_CN.UTF-8
language message zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"自动补全
filetype plugin indent on
set completeopt=longest,menu
"自动补全命令时候使用菜单式匹配列表
set wildmenu
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType java set omnifunc=javacomplete#Complet
" --------------- 树形目录 ---------------
" F2开启和关闭树
map <F2> :NERDTreeToggle<CR>
let NERDTreeChDirMode=1
" 显示书签
let NERDTreeShowBookmarks=1
" 设置忽略文件类型
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
"窗口大小"
let NERDTreeWinSize=25
" --------------- 语法分析 ---------------
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" --------------- JSON格式化---------------
" TODO
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" 树形目录
Bundle 'scrooloose/nerdtree'
" 语法检测
Bundle 'scrooloose/syntastic'
" 代码补全
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
Plugin 'honza/vim-snippets'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
安装插件
$ vim +PluginInstall +qall