考虑将 Rails 开发从 TextMate 迁移到 vim。我需要什么?
我几乎专门从事 Ruby on Rails 开发。我目前使用 TextMate 在 OS X 中进行开发。我运行了一个虚拟机来尽可能模拟我的应用程序将部署到的环境,并且我将 Samba 共享上的代码从 VM guest 装载到 OS X 中。从那里我使用 TextMate 打开并编写代码。
我开始认为,通过适当的插件和花时间学习,我可以直接在虚拟机上使用 vim 提高工作效率。现在我的 TextMate 基本上是库存的,尽管我确实发现 ProjectPlus 插件不可或缺。我正在寻找一些 vim 资源和插件的建议(如果这是正确的术语),以紧密模拟我不愿意在 TextMate 中放弃的功能。或者至少,有令人信服的理由让我愿意放弃它们。下面是一个简短的列表:
- 能够让(最好是)可折叠的项目树始终可见或轻松切换。
- 能够一目了然地查看 SCM 状态,无论是在此项目树中(最好)还是其他位置。 (如果这有什么区别的话,我几乎只使用 git。)
- 能够在 vim 中查看并排差异也很棒
- 能够随意搜索整个项目(我想
:stop; grep -nr; fg;
会完成这个,除非有更好的方法来做到这一点。) - 代码完成,如果可能的话
I do Ruby on Rails development pretty much exclusively. I currently develop in OS X using TextMate. I have a virtual machine running to emulate as closely as possible the environment my app will be deployed into, and I mount the code on a Samba share into OS X from the VM guest. From there I open with TextMate and code away.
I'm beginning to think that with the proper plugins and time spent learning, I could be much more productive in vim directly on the VM. Right now my TextMate is basically stock, though I do find the ProjectPlus plugin indispensable. What I'm looking for are some suggestions of vim resources and plugins (if that's the right terminology) to closely emulate the features I am unwilling to give up in TextMate. Or at least, compelling reasons why I should be willing to give them up. Here's a short list:
- Ability to have a (preferably) collapsible project tree visible either at all times or easily toggle-able.
- Ability to see SCM status at a glance, either within this project tree (preferable) or otherwise. (I use git almost exclusively if this makes any difference.)
- Being able to view a side-by-side diff from within vim would be great too
- Ability to search through the entire project at will (I suppose
:stop; grep -nr; fg;
would accomplish this, unless there's a better way to do it.) - Code completion, if possible
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我今天发表了一篇关于这个主题的扩展文章,其中解释了如何在 VIM 中复制 Textmate 的 100 个功能。它是大量时间研究的成果。
例如,我解释:
阅读原文: Textmate 到 VIM
I published an extended post on this topic today, in which I explain how to replicate 100 features from Textmate within VIM. It's the product of a great deal of hours research.
For example I explain:
Read Original Article: Textmate To VIM
NERD Tree 插件为您提供了一个可折叠的项目树。就我个人而言,我发现 netrw 插件就足够了,而且通常会安装这个插件与维姆。虽然 NERD 树感觉好像它试图模拟其他 IDE(以及 TextMate 的项目抽屉)的行为,但我觉得 netrw 插件以 Vim 的方式做事。我建议您都尝试一下,看看您更喜欢哪一个。
fugitive 插件为 Vim 提供了一个 git 接口(参见 Vimcasts:部分1, 2, 3, 4 和 5) 。
ack 插件非常适合搜索整个项目。您需要阅读 Vim 的 quickfix 列表,以充分利用此功能。
TextMate 的单词补全由 esc 和 shift-esc 触发。在 Vim 中,您可以使用 ctrl自动完成 功能>-n 和 ctrl-p 处于插入模式。检查
:help ins-completion
(很多!)更多信息。我正在 vimcasts.org 上播放一系列有关学习 Vim 的截屏视频。我的背景是使用 TextMate,但我现在已经全职使用 Vim 一段时间了。当我写这篇文章时,我只看了 6 集,但我确实计划在未来的剧集中涵盖您提出的每个要点。我会尝试回来编辑这个答案,并在截屏视频可用时提供链接。
The NERD Tree plugin gives you a collapsible project tree. Personally, I find that the netrw plugin is more than sufficient, and this usually comes installed with Vim. Whereas the NERD tree feels as though it tries to emulate the behaviour of other IDEs (and TextMate's project drawer), I feel that the netrw plugin does things the Vim way. I suggest you try both out, and see which one you prefer.
The fugitive plugin provides a git interface to Vim (See Vimcasts: parts 1, 2, 3, 4 and 5).
The ack plugin is great for searching an entire project. You'll want to read up on Vim's quickfix list to get the most out of this.
TextMate's word completion is triggered with esc, and shift-esc. In Vim, you get similar autocomplete functionality using ctrl-n and ctrl-p in insert mode. Check
:help ins-completion
for (much!) more info.I am running a series of screencasts about learning Vim over at vimcasts.org. My background is with TextMate, but I've been using Vim fulltime for a while now. As I write this, I'm only 6 episodes in, but I do plan on covering each of the points you've raised in future episodes. I'll try and come back to edit this answer with links to the screencasts as they become available.
以及 snipMate :Vim 的 TextMate 风格片段
And snipMate : TextMate-style snippets for Vim
我目前的处境与您类似(从 TextMate 迁移到 Vim)
一个非常好的资源是:
http://robots.thoughtbot.com/post/166073596/intro-rails-vim
祝你好运!
I'm currently in a similar position to you (moving from TextMate to Vim)
One really good resource is this:
http://robots.thoughtbot.com/post/166073596/intro-rails-vim
Good luck with it!
对于文件导航来说简直就是喜欢 CommandT
这个功能与 textmate 中深受喜爱的 commandT 功能非常相似。
For file navigation is simply love CommandT
This functions very much the same as the beloved commandT function in textmate.
您可能想从我的 Ruby/Rails 相关 vimfiles 开始,其中包括对 rvm 和 git 的支持。
You might want to start with my Ruby/Rails related vimfiles which includes support for rvm and git.
这个截屏视频也很棒 http://blip.tv/file/1372096
我确实使用 VIM 并且我特别喜欢如何从模型/视图和控制器相关的旋转。
This screencast is great as well http://blip.tv/file/1372096
I do use VIM and i specially like how to rotate from model/view and controller related..
查看博客文章: 从 Textmate 到 VIM for Rails 编码员。
那里的评论可能对您也很有价值。
Check out the blog post: From Textmate to VIM for Rails coders.
The comments there may also valuable for you.
所有其他答案加上:
:help mkview
和:help mksession
也可以提供帮助。:help fugitive-statusline
。:Gdiff
命令就可以做到这一点。
在另一个窗口中打开以前的提交,然后点击D
查看双重差异。
、
和 < code>All of the other answers plus:
:help mkview
and:help mksession
can help, too.:help fugitive-statusline
.:Gdiff
command that does just that.<CR>
to open a previous commit in another window andD
to see a double diff.<C-x><C-o>
,<C-n>
and<C-p>
will be more than enough, if you want "autocompletion" you may try these few plugins. My favorite is autocomplpop.此处搜索整个项目。
代码补全:通常使用 ctrl-X 然后 ctrl-O。
Git 集成:git.vim
项目树:Nerdtree.vim
祝你好运
Search an entire project here.
Code completion: Normally done with ctrl-X then ctrl-O while in insert mode.
Git Integration: git.vim
Project Tree: Nerdtree.vim
Good luck