说谎的爱人电视剧简介:[Ruby on Rails]Vim 开发 ruby on rails 完全配置1

来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 08:02:00

用vim写rails越来越顺手了,估计不会再考虑用别的了,共享一下自己的配置。。。

首先应该感谢vim的作者们以及文中使用到的所有插件的编写者,是他们才使rails的开发如此方便。

以下为winxp环境,安装gvim 7.0 安装路径为: d:\gVim
一般安装插件,如果是zip/gz之类的文件直接解压到gvim.exe同一目录(d:\gVim),如果是.vim文件则直接放在gvim.exe下的plugins目录(d:\gVim\plugins)就OK了。

使用到了ftplugin所以需要在D:\gVim\_vimrc中增加:filetype plugin on 这一行

1.安装rails.vim (rails.vim)
毋庸置疑啦,首先肯定是装它了。11.1出的新版本(小修改并支持surround.vim-见下文),下载rails.zip解压到gvim.exe所在的目录(D:\gVim\vim70) 安装完成。
使用方法及更多说明见本站:vim+rails.vim ruby on rails (ror)开发的利器 及docs下的rails.txt

2.安装project (project-1.4.1.tar.gz)
项目导航,方便的浏览打开文件(我只用到这个功能) 在rails项目中使用 :Rproject 打开。
也许你要说了rails.vim不是很方便的切换各种文件吗?为什么还要装这个呢?
是的rails.vim确实很方便,经过实践得出:有时候你要打开css之类的文件就不那么方便了(先打开Rlayout 再gf到css,或是我不会用?)还有就是当你的model和migrate不对应的话也不方便。所以有时候还是要用鼠标点来得快。

3.安装ruby_imaps (ruby_imaps.zip)
这可是个好东西,原来很羡慕人家mac下的textmate不过有了这东西,咱也不错了,而且自己hack还很简单。
详细命令见包中的ftplugin中的ruby_imaps.vim,命令很多,但是常用的也就那几个。我自己hack了一下,加了几个在rhtml中常用的标签,link_to for in end 啊之类的。请到这里下载>>> 下载。。(2006.12.14 今天没搞完,这两天把改完的传上来,不好意思。)
欢迎大家把自己hack的东西发一份给我,谢谢。。。
在不同的编辑位置切换用 ctrl+j

This is (another) snippets script that tries to emulate what I’ve seen of Textmates snippets feature (I haven’t used Textmate, so this assumption is based on rails screencasts I’ve watched).

This uses imaps.vim. A *great* script originally written by Srinath Avadhanula and modified by Benji Fisher. It is part of the latex suite of scripts but I’ve included it here with Srinaths and Benjis permission. (If you use latexsuite then there is no need to install the file again).

4.安装surround.vim (surround.zip)
Surround.vim is all about “surroundings”: parentheses, brackets, quotes, XML tags, and more. The plugin provides mappings to easily delete, change and add such surroundings in pairs. While it works under Vim 6 but much of the functionality requires Vim 7.
对于加速编辑还是很有用的。详细说明见:http://www.vim.org/scripts/script.php?script_id=1697

5.安装closetag.vim (closetag.vim)
就是在编辑html时 ctrl+_(下划线)关闭html标签用的(如aaa时使用就补)
又有人要说了:为什么不用html自动完成?是的我用过html.vim,挺好用的。。不过它生成的标签是大写的,不符合xhtml标准,否了。

6.dbext.vim
rails.vim作者提到过这东西,数据库操作的,我试了一下,感觉我自己用不上。

还些ruby代码补全之类的我就不多说了。觉得不怎么用。http://www.vim.org/上搜索一下应该很多