Thinking of moving from TextMate to vim for Rails dev. What do I need?

女生的网名这么多〃 提交于 2019-12-04 07:27:19

问题


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

回答1:


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.




回答2:


And snipMate : TextMate-style snippets for Vim




回答3:


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!




回答4:


For file navigation is simply love CommandT
This functions very much the same as the beloved commandT function in textmate.




回答5:


You might want to start with my Ruby/Rails related vimfiles which includes support for rvm and git.




回答6:


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..




回答7:


Check out the blog post: From Textmate to VIM for Rails coders.

The comments there may also valuable for you.




回答8:


All of the other answers plus:

Ability to have a (preferably) collapsible project tree visible either at all times or easily toggle-able.

  • The project.vim plugin doesn't really work like TextMate's Project drawer but it's close.
  • With NERDTree, you can setup bookmarks and make it work a little like a project drawer.
  • :help mkview and :help mksession can help, too.

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.)

  • vcscommand.vim provides the same set of commands for multiple SCMs, it works with Git, SVN, Mercurial…
  • You can use the aforementioned fugitive plugin to display the Git status in the status line, :help fugitive-statusline.

Being able to view a side-by-side diff from within vim would be great too

  • fugitive provides the :Gdiff command that does just that.
  • A recently released plugin called Gitv tries to emulate GitK in Vim. I like it a lot and the author is very responsive. In the tree view, hit <CR> to open a previous commit in another window and D to see a double diff.

Code completion, if possible

  • There are a few solutions, if you don't need it to be automatic <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.



回答9:


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




回答10:


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:

  • How to replicate a Project Drawer
  • How to manage tabs
  • How to do Rails specific commands (Lets face it: A lot of Textmate users are Rails programmers)
  • How to do find and replaces
  • How to do project wide searches

Read Original Article: Textmate To VIM



来源:https://stackoverflow.com/questions/2269230/thinking-of-moving-from-textmate-to-vim-for-rails-dev-what-do-i-need

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!