mac vim sourcing html indent,在Mac上使用vim代替SourceInsight

一直以来在Mac上找不到好的代码阅读工具,最近根据网上的教程,自己总结一下,做了个在Mac的类sourceinsight的vim,感觉很好用。我不喜欢那种把vim搞的很复杂的配置,所以做了个仅仅能满足浏览代码的vim。

使用homebrew安装必要的插件

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

[id]:http://brew.sh/index_zh-cn.html

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自动安装相关插件并配置

粘贴这段内容到vim中:

"设置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(注意使用sudo),按ESC后输入:BundleInstall后回车,系统会自动安装这些插件。安装完成后重新启动vim,这时按下F2,F3,F4,就看到sourceinsight的那些功能和界面了。强烈建议使用MacVim看代码。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值