Mac从零配置Vim

 

 

1. 安装Homebrew (包管理器,用来安装Vim)
& /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2.安装Vim(系统自带的Vim不是最新版)
& brew install wget

3.建立并编辑配置文件 (不使用任何插件情况下一些有用的配置)
& cd ~
& touch .vimrc
& vim .vimrc
编辑配置文件为:

"  输入:make编译并运行
set makeprg=clear;gcc\ %\ &&\ ./a.out

 

 " 当前行高亮
au WinLeave * set nocursorline nocursorcolumn
au WinEnter * set cursorline
set cursorline
 

colorscheme default       " 颜色主题

syntax enable                 " 启用语法分析着色
 
set tabstop=4                  " 设定Tab表示的空格数
set softtabstop=4            " 设定输入Tab表示的空格数
set expandtab                 " 将Tab视为若干空格
set backspace=2            " 设置退格键可用 
 
set number                      " 显示行号
set showcmd                   " 右下角显示待补全命令
 
set hlsearch                     " 搜索字符串时高亮所有结果,:nohlsearch取消高亮
 

4. 安装Vundle(Vim 插件管理器)
& git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

& vim .vimrc
在配置文件开头添加如下配置:

"---START OF VUNDLE---
set nocompatible
filetype off
 
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
" Plugins start
 
" Plugins end
call vundle#end()
filetype plugin indent on
" ---END OF VUNDLE---

5.  用Vundle安装插件的一般流程
在GitHub找插件,记下名字。
& vim .vimrc
在配置文件 "Plugins start 和 end 注释之间加入:
Plugin '[插件名]' 
:wq
& vim .vimrc
:PluginInstall 

清除不在此列表中插件的命令是:
:PluginClean 

6. 用Vundle安装颜色主题molokai
在配置文件中加入:
Plugin 'tomasr/molokai'
并安装(详见第5条)。

在配置文件中colorscheme default一行改为:
colorscheme molokai

7. 用Vundle安装YouCompleteMe插件(for C/C++)
& xcode-select --install
& brew python 
& pip install future
& brew CMake

在配置文件中加入:
Plugin 'Valloric/YouCompleteMe'
并安装(详见第5条)。

& cd ~/.vim/bundle/YouCompleteMe
& ./install.py --clang-completer

在配置文件" ---END OF VUNDLE--- 注释后加入:
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
posted @ 2016-12-04 15:19  杨乐达  阅读(1286)  评论(0编辑  收藏  举报