简体   繁体   中英

How to run rails inside vim without switching windows

I've a beginners question to working with Rails in Vim. I've installed Rails.vim and can run all the commands from within vim that I need. What I don't understand is why vim switches back to terminal when I run something like

:Rake db:migrate 

where i see the output of the command and "Press Enter to Continue" - When I switch back to vim - I can see the results of the rails.vim command inside the vim editor. Is there anyway I can keep it all within vim - it's already capturing all the output with better formatting than terminal.

Many thanks!

Btw: Im using Mac Vim 7.3

My friend, I'm afraid that's not possible... Vim switch to terminal mode to run the commands that you are applying ... from vim, you can run all the terminal commands you want with the symbol "!" (See here for more details: https://superuser.com/questions/285500/how-to-run-unix-commands-from-within-vim ). The best solution would be to run the rails commands in another terminal. Best Regards. Leo

Running Rails commands in a separate terminal is the easiest solution in my experience. I too am on a Mac and eventually gave up on MacVIM partially because of what you are experiencing. I switched to iTerm and tmux using plain VIM. The only downside to this setup is you lose the ability to map anything to the Apple-key (only a problem for me because I wanted to keep some of my Textmate style keybindings).

I eventually made myself a little init script to get a tmux/vim session up and running. If it might be useful check it out: frankjmattia/tmuxide

Just clone it, add it to your path and run tmuxide path/to/rails/app . It will cd into your project directory so if you have something like Command-T or Ctrl-P installed in vim you'll be where you want to be.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM