记录vim的配置,随时更新
MacVim
安装:
- homebrew,安装位置:/usr/local/Cellar
- brew linkapps macvim——将macvim.app加入到Application下
- alias vim=”/Applications/MacVim.app/Contents/MacOS/Vim”——设置别名,默认在终端中使用macvim的命令行版(关闭终端后会失效,在~/.zshrc中设置才行)
插件
vundle
- 说明:vim下安装其他插件的插件
- 安装:git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle,在./vimrc中添加配置:Bundle ‘gmarik/vundle’。(/.vim/bunle为vim的插件目录)
- 使用:
- Bundleinstall:安装插件,BundleIstall ‘author/projectname’
- BundleList:列出当前安装的插件
- BundleUpdate:更新插件
- BundleSearch:搜索插件
- BUndleClean:清除插件
NERDTree
- 说明:树形结构目录
- 安装:使用vundle安装
- 配置:在.vimrc中设置快捷键:nmap :NERDTreeToggle ,可用切换
YouCompleteMe
- 说明:自动补全多种程序语言
- 安装:使用vundle安装
supertab
- 说明:使用tab补全,代替ctrl+p,ctrl+n
- 安装:使用vundle安装
.vimrc配置
filetype off " required!
filetype plugin indent on
colorscheme molokai
"Vundle"
call vundle#rc()
" let Vundle manage Vundle
Bundle 'gmarik/vundle'
Bundle 'scrooloose/nerdtree'
nmap <F2> :NERDTreeToggle <CR>
Bundle 'Valloric/YouCompleteMe'
Bundle 'ervandew/supertab'
set nocompatible " be iMproved
set rtp+=~/.vim/bundle/vundle/
set fencs=utf-8,chinese
syntax on "打开语法高亮
set showmatch
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set nu "显示行号
set mouse=a "设置鼠标定位光标"
set pastetoggle=<F10> "设置粘贴模式快捷键"
set clipboard=unnamed "vim剪贴板与系统剪贴板适配"
"括号自动补全"
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {}<ESC>i
inoremap " ""<ESC>i
inoremap ' ''<ESC>i
"Youcompleteme config"
let g:ycm_global_ycm_extra_conf = '/Users/zhengjt/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
"python F5 to run"
au BufRead *.py map <buffer> <F5> :w<CR>:!/usr/bin/env python % <CR>