Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm aware I can do !commands but I'd like to somehow integrate a shell in vim. Or could I use screen and split the screen so that vim takes up say, half of the screen?

share|improve this question
add comment

4 Answers

up vote 9 down vote accepted

CtrlZ will suspend vim and return control to bash. Use fg to return to vim.

share|improve this answer
add comment

Integrating subprocesses is Vim's main weak point. There's no built-in support for a shell window, but you can try the vimsh plugin.

In Screen, press C-a c to create a new (full-screen) window. Press C-a p or C-a n to move to the previous/next window (C-a space also moves to the next window). Also the split command (C-a S) will split your screen into two regions; you can use one for a shell and one for Vim. Press C-a tab to switch between regions.

You can always press Ctrl+Z to suspend Vim and run commands in the parent shell; type fg to return to Vim. Or you can use :shell to create a (full-screen) subshell; type exit to return to Vim.

share|improve this answer
add comment

As you suggest, I would just use screen.

  • screen
  • ^A-c to create a new window
  • ^A-S to split the screen horizontally into two regions (some versions have Ctrl-| to split vertically)
  • ^A-Tab to move to the new region
  • ^A-n to change the region to the next window

If you don't want exactly half and half you can:

  • ^A-+ to increase the size of the current region

If you need to see what's in vim when you're on the command line, this is a good way to go. If you don't the Ctrl-Z/fg method already mentioned is the way to go.

share|improve this answer
add comment

You can also use :shell to just spawn a shell. Type exit or Ctrl+D to exit the shell and return to vim. If you want both running simultaneously, using fg/bg (per Ignacio), screen (as you suggested) or just two separate terminals (xterms, virtual consoles, whatever) are about your best options.

If you go to vim.org, you can probably find an extension which launches a shell directly, but you're getting dangerously close to emacs at that point. ;) Here's an example using screen: http://www.vim.org/scripts/script.php?script_id=2711

share|improve this answer
1  
"you can probably find an extension which launches a shell directly, but you're getting dangerously close to emacs at that point". Stop that talk, you're scaring the children. –  Greg Nov 12 '10 at 23:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.