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?
I'm aware I can do
CtrlZ will suspend vim and return control to bash. Use
fg to return to vim.
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.
As you suggest, I would just use 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
fg method already mentioned is the way to go.
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
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.– TTMNov 12, 2010 at 23:45