概述
用了一段时间的Atom莫名其妙的挂了,看网上推荐MacVim的不少,也想通过它弥补Vim编程不熟的遗憾,开始折腾一波MacVim。MacVim就是一个Mac OS上的自带编辑器加Vim的实现,命令和Vim是一样的。
阶段一需求
分析一下自己对MacVim的需求,最后看下搞出来是个啥样子:
- 目录树
- 代码补全
- 窗口分割和切换
- 状态栏
阶段一效果
对应配置
" *********************************************
" Vbundle插件管理
" *********************************************
set nocompatible " 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 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'Valloric/YouCompleteMe'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" Add all your plugins here (note older versions of Vundle used Bundle instead of Plugin)
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" ***************
" 切换窗口键盘指令
" ***************
" 向下
nnoremap <C-J> <C-W><C-J>
" 向上
nnoremap <C-K> <C-W><C-K>
" 向右
nnoremap <C-L> <C-W><C-L>
" 向左
nnoremap <C-H> <C-W><C-H>
" **********************
" 目录树插件NERDTree配置
" **********************
" 开启vim时默认开启NERDTree
au vimenter * NERDTree
" 设置开启NERDTree快捷键
map <F2> :NERDTreeToggle<CR>
" ************
" 代码补全相关
" ************
let g:ycm_autoclose_preview_window_after_completion=1
" 跳转到定义处
map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
" 默认tab、s-tab和自动补全冲突
let g:ycm_key_list_select_completion = ['<TAB>', '<c-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<S-TAB>', '<c-p>', '<Up>']
let g:ycm_auto_trigger = 1
" ***********
" vim-airline
" ***********
开启powerline字体
let g:airline_powerline_fonts = 1
" 使用powerline包装过的字体
set guifont=Source\ Code\ Pro\ for\ Powerline:h14
需要主要的是装YouCompleteMe
后老是会有一个错误提示,Error detected while processing function youcompleteme#Enable[3]..<SNR>
,解决的办法是找到YouCompleteMe
对应的代码,将那个错误提示改掉,文件是/autoload/youcompleteme.vim
,改动如下代码。
function! s:SetUpPython() abort
- exec s:python_until_eof //原始代码
+ silent! exec s:python_until_eof //修改后代码