Create a “project” in VIM / MacVim / GVIM

I am VIM noob, and I am returning to it again and again, and this time I hope to actually stick to it. First of all, I program in TextMate with Ruby on Rails. On the recommendation of someone, I installed Janus (https://github.com/carlhuda/janus) and his help a lot. But one thing that I am missing is the “project” so that I can quickly return to the project quickly.

I want to be able to run a copy of macvim, pointing to a file or pointing to a command, upload the project back to where I last left it. It means:

  • CD to the root of the project
  • Install backups of all tabs / sections that I installed in their places
  • Open the files I was working on for the last time.
  • Today I am going to explore Conque Shell (http://code.google.com/p/conque/), and if that works, I would like these shells to reboot and run their launch commands as well. (CD to the root of the project, starting the rails server, log tail, etc.).

Suggestions? I want to optimize my process by simply clicking on a shortcut or running a command, and after a few seconds I will look at my development environment, where I left it last.

Bonus: I often use windows, so the ability to do the same in GVim will also be great.

thanks for the help

+8
vim macvim
source share
3 answers

For the Rails developer, there is a famous Tim Pope plugin called rails.vim .

Once you are at the root of the rails project (you can change the current Vim directory with :cd /path/to/project/root ), rails.vim provides quick access to your file, for example:

  • : Rcontroller file
  • : Rview file
  • : Rstylesheet file

These are other partial refactoring options. Install it and type :help rails.txt . There are many nice features. It is very useful to speed up access to your project files.

You can probably combine it with session.vim , which provides the ability to automatically restore a previous session.

If you do not want to enter the path to the project, one of the possible solutions is to add the following code at the end of your .vimrc:

  if isdirectory("~/workspace/project1") cd ~/workspace/project1 endif 

This way you always run Vim in the current workspace. Obviously, if you need to switch to another directory, you need to manually edit your .vimrc ... which is the best fit.

+2
source share

You might want to check out Vim's built-in ability to create recovery sessions. This allows you to save almost everything you have, including cwd, folds, split, buffers, vars, etc. See :help :mksession .

Here are two plugins that help with saving and restoring sessions:

You can also check out the project plugin: http://www.vim.org/scripts/script.php?script_id=69

I also heard well about rails.vim.

+8
source share

Terminitor (Ruby Gem) will not specifically solve your "vim" project goal, but it will solve the rest of your problem. You can customize the terminal windows, and then run the command to capture the positions and sizes of the terminal, edit the configuration to add any other commands (in Ruby) that you want to execute, and this will allow you to restore your environment.

0
source share

All Articles