最近在使用vim插件CommandT时出现问题其实就是vim没有支持ruby,不过google之后找到了解决方法,老外的态度还是很让人敬佩的,度娘搜索的结果太让人呕心了。。

贴下,以后再次遇到解决。

One of the first things I do after installing a fresh copy of Ubuntu is grab an updated Vim with RubySupport and proceed to install the amazing Command-t plugin. However, this isn't exactly the most straightforward process. So I thought it would be a good idea to document the process and share it with you all. So without further ado, let's get started!

Install Vim with Ruby Support

The first thing you want to do is open your terminal and install vim-nox. Vim-nox is a minimal version of Vim that allows you to run Vim in your terminal, and comes compiled with Ruby support. Here is a link that will explain all the Vim versions in detail.

sudo apt-get install vim-nox

Your vi and vim commands should now call vim-nox instead of your system's default Vim. Let's restart our terminal after you have installed this just to make sure.

Install Pathogen - Vim Plugin Manager

highly recommend installing Pathogen for managing your Vim plugins. Pathogen just makes installing plugins simpler and keeps them organized better. Run the following install Pathogen.

mkdir -p ~/.vim/autoload ~/.vim/bundle; \
curl -Sso ~/.vim/autoload/pathogen.vim \
https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim

Now at the top of your ~/.vimrc file, add this line:

execute pathogen#infect()

Alternatively, if you don't already have a ~/.vimrc, you can create this minimal version of a .vimrc:

execute pathogen#infect()
syntax on
filetype plugin indent on

This is the Github page for Pathogen, I recommend skimming over it if you have time.

Install Command-t

To install the Command-t plugin, you can either use git, or manually download and install it to your~/.vim/bundle directory.

Using git

cd ~/.vim/bundle
git clone https://github.com/wincent/Command-T.git

Manually installing

Go to the Command-t Github page and click the Download Zip button. Extract the contents of zip file to the~/.vim/bundle directory.

Pathogen will automatically run plugins in ~/.vim/bundle when you start Vim

Install RVM and Ruby

Skip this next part if you already have Ruby and RVM installed already

You can check if you have Ruby installed by doing ruby -v and rvm -v

If you get a message saying The program 'ruby' can be found in the following packages, you need to install Ruby and rvm.

1. Install rvm dependencies

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev \
curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev \
sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake \
libtool bison subversion nodejs

2. Install rvm

curl -L https://get.rvm.io | bash -s stable --ruby

3. Set .bashrc for rvm scripting

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc

Now you can restart your terminal, and ruby -v should work.

Compile Command-t using the Ruby version that your Vim is installed with

If you see the error: command-t.vim could not load the C extension when you try to runCommand-t in your Vim, this section will help solve that problem.

This is the part that trips most people up. You must compile Command-t using the same version of Ruby that your Vim is linked against. This basically means that if your Command-t's Ruby version doesn't match your Vim's Ruby version, Command-t will not work. First let's find your system's version of Ruby.

Compare the versions of Ruby from the following two commands:

ruby -v
vim --version | grep ruby

You should see something similar to the following screenshot:

Here are the following steps to now compile Command-t with the correct Ruby version:

1. Install and use the version of Ruby that matches your Vim's

Find the version of Vim from the command we ran earlier vim --version | grep ruby (in my case, it's1.8). Just look through the output and it should be a number like 1.8 or 1.9.1 or 2.0.0, something similar to that. Next do:

rvm use #YOUR_VIM's_VERSION_OF_RUBY

For example, in my case, my Vim was compiled with Ruby version 1.8, so my command would bervm use 1.8. If you get a message saying like ruby-1.8.7-p374 is not installed., follow theTo install do: 'rvm install ruby-1.8.7-p374' warning in your console. Again please use the version of Ruby that your Vim is installed with.

After you have installed the proper version of Ruby, make sure that your system is actually using it.

rvm use #YOUR_VIM's_VERSION_OF_RUBY

2. Navigate to your Command-t bundle directory

cd ~/.vim/bundle/Command-T

3. Compile Command-t using your Vim's Ruby Version

Now that you are in your Command-t bundle directory. Do the following:

rake make

That should recompile Command-t with the proper version of Ruby, and your Command-t's and Vim's Ruby versions should now match.

Run Command-t

Now for all of your hard work, reward yourself by opening Vim and running Command-t to see its awesomeness.

vim
:CommandT

If you have any problems, comment below and I will try to answer ASAP. Well, hope this helps someone out, thanks for reading!

不过其中有些注意点需要知道的就是vim的版本和ruby版本一定要对应关联起来,这是个大坑。。。

最新文章

  1. 为.NET Core项目定义Item Template
  2. PHP面向对象
  3. OpenFlow:Enabling Innovation in Campus Networks
  4. Linux编译源码的方式安装Qt4开发环境(基于Ubuntu系统)
  5. SQL设置SQLServer最大连接数查询语句
  6. 自动获取wordpress日志中的第一张图片作为缩略图
  7. UVA 562 Dividing coins (01背包)
  8. Solution中的auto test case组织方式
  9. ios游戏开发--cocos2d学习(1)
  10. Linux下用来获取各种系统信息的C++类
  11. DAC,MAC和SELinux,SEAndroid
  12. 一次项目中用到的php函数总结
  13. DLL入门浅析(4)——从DLL中导出类
  14. C#文件压缩
  15. BytesWritable 存储问题
  16. IDEA + Maven + JavaWeb项目搭建
  17. vue图片onerror加载路径写法
  18. Linux 驱动——Button驱动4(fasync)异步通知
  19. Swift中使用oc代码桥接设置
  20. Unity IOC容器的构造函数使用笔记(不能错过的Unity示例)

热门文章

  1. c#二进制、十进制、16进制之间的转换
  2. c#实现Google账号登入授权(OAuth 2.0)并获取个人信息
  3. Java学习笔记——JDBC之PreparedStatement类中“预编译”的综合应用
  4. 用py2exe打包pyqt4出现的问题(转)
  5. C#代码和javascript函数相互调用
  6. 利用HttpWebRequest和HttpWebResponse获取Cookie并实现模拟登录
  7. QQ空间如何显示相片
  8. CXF.bat
  9. 纯Java代码 图片压缩
  10. 汇编条件判断整理(JCC,CMP/TEST的实现)