在mac上安装macvim

首先我们需要安装homebrew,在终端输入下面命令安装:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

安装完成后,运行下面代码安装vim和mac vim:

brew install vim
brew install macvim
brew install ctags
brew install cscope

设置Mac上的ctage和默认的vim

现在已经安装了必备的软件了,但是Mac下Xcode也有一个程序叫ctags,而且mac也自带vim,所以我们需要修改系统变量:

sudo vim /etc/paths

系统默认将/usr/bin放在第一行,只需要将/usr/local/bin放在第一行就可以了:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

经过这样的配置,就可以使用最新版的vim了。

用ctags和cscope解析代码

接下来在代码的根目录运行:

ctags -R
cscope -Rbq

使用vundle自动安装相关插件并配置

首先需要安装vundle,否则会报错的
在用户目录下创建.vimrc文件  注意查看的时候要用ls -a 来查看隐藏文件

粘贴这段内容到.vimrc中:

"设置vundle
set nocompatible              " be iMproved
filetype off                  " required!

set rtp+=~/.vim/bundle/vundle/
call vundle##rc()

Bundle 'scrooloose/nerdtree'  "文件浏览
Bundle 'majutsushi/tagbar'    "代码符号
Bundle 'wesleyche/SrcExpl'    "类似sourceInsight的代码预览窗口
filetype plugin indent on     " required!
"vundle设置完毕

syntax on
let g:tagbar_ctags_bin='/usr/local/bin/ctags'
let g:tagbar_left = 1
nnoremap  :TagbarToggle
let NERDTreeWinPos='right'
nnoremap  :NERDTreeToggle
nmap  :SrcExplToggle
let g:Srcexpl_winHeight = 8
" // Set 100 ms for refreshing the Source Explorer
let g:SrcExpl_refreshTime = 100

" // Set "Enter" key to jump into the exact definition context
let g:SrcExpl_jumpKey = ""

" // Set "Space" key for back from the definition context
let g:SrcExpl_gobackKey = ""

let g:SrcExpl_pluginList = [
         \ "__Tag_List__",
                 \ "_NERD_tree_"
                     \ ]


set tags=tags;/  "搜索上一级建立的tag



nmap  h "control+h进入左边的窗口
nmap  j  "control+j进入下边的窗口
nmap  k "control+k进入上边的窗口
nmap  l  "control+l进入右边的窗口

保存后,再使用vim后,发现报错,报错如下:

Error detected while processing /Users/lizhiyong/.vimrc:

line    6:

E117: Unknown function: vundle##rc

line    8:

E492: Not an editor command: Bundle 'scrooloose/nerdtree'  "文件浏览

line    9:

E492: Not an editor command: Bundle 'majutsushi/tagbar'    "代码符号

line   10:

E492: Not an editor command: Bundle 'wesleyche/SrcExpl'    "类似sourceInsight的代码预览窗口

Press ENTER or type command to continue


提示的错误是在.vimrc中不认识vundle及Bundle这两个函数,解决办法就是安装vundle

vundle,基于git仓库的插件管理软件。

vundle将插件的安装简化为类似yum软件安装的过程,只要:BundleInstall插件就安装完了,:BundleClean之后插件就卸载了。

更换机器时,在新机器上安装vundle并使用老的vundle配置,即可安装所有配置好的插件。

安装:

$ git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle  


保存后,重新启动vim,按ESC后输入:BundleInstall后回车,系统会自动安装这些插件。

安装过程也比较诗意

在mac上安装macvim_第1张图片

安装完成后重新启动vim,这时按下F2,F3,F4,就看到比较新颖的东西了。如果在mac上执行F2 F3 F4是执行屏幕操作的话,那就配合使用fn键。

你可能感兴趣的:(MAC&IOS)