tags:

views:

2072

answers:

7

I am used to emacs but I am trying out vim to see which one I like better. One thing that I like about emacs is the ability to run a terminal inside emacs. Is this possible inside of vim? I know that you can execute commands from vim, but I would like to be able to run a terminal inside of a tab.

+9  A: 

No, you cannot:

http://www.vim.org/htmldoc/tips.html#shell-window

Amber
+1  A: 

Only way I know of is by using vim-shell, a third-party patch.

romandas
To be pedantic, vim-shell is a patch, not an 'add-on' (which to me, at least, implies that it's a script). I haven't tried it personally, but the vim-shell page on the Vim wiki unfortunately suggests that it won't compile with Vim 7.1+.
Steve K
Changed to appease the pedant. :) (Had to type something longer than 15 characters. 'Fixed' wasn't long enough)
romandas
+4  A: 

I'm not sure exactly what you're trying to achieve (I've never used emacs), but you can run commands in vim by typing:

:! somecommand [ENTER]

and if you want to type in several commands, or play around in a shell for a while, you can always use

:! bash (or your favourite shell) [ENTER]

once the command or shell terminates, you'll be given the option to press [ENTER] to return to your editor window

vim is intentionally lightweight and lacking in the ability to do non-editorish type things, just as running a full-blown shell inside a vim pane/tab, but as mentioned above there are 3rd party addons such as vim-shell that allow you to do that sort of thing

typically if I want to switch between vim and my shell (bash), I just hit CTRL+Z to pause the vim process, play around in my shell, then type 'fg' when I want to go back to vim - keeping my editor and my shell nice and separate.

David Claridge
And if you want to copy the command's output to the current buffer::r! dir
Leonardo Constantino
+17  A: 

I would definitely recommend screen for something like this. Vim is a text editor, not a shell.

I would use Ctrl+AS to split the current window horizontally. Then use Ctrl+ATab (or equivalently, Ctrl+ACtrl+I which may be easier to type) to switch between the windows. There are other commands to change the size and arrangement of the windows.

Or a less advanced use of screen is just to open multiple full-screen windows and toggle between them. This is what I normally do, I only use the split screen feature occasionally.

The GNU Screen Survival Guide question has a number of good tips if you're unfamiliar with its use.

Greg Hewgill
+1 I only just recently recieved the screen gospel. I wonder how I lived without it.
guns
You can also use screen with Vim plugin Vicle to send commands edited in vim to a screen session.
skinp
I'm not sure if you can do it in the stock screen, but Ubuntu's version lets you do vertical splits with Ctrl+A | (that's a vertical pipe). Much nicer, imo.
Steve K
If I could I'd vote twice for this. I heard about screen long ago but never used it. This tip will save me a LOT of time. thanks.
yogsototh
Unfortunately, using a vertical split slows down STDOUT (at least on my machine). `ls -R` is a lot slower with the split than without, for example.
Benjamin Oakes
+2  A: 

You might want to take a look at the :sh command (see :help sh in vim).

http://vimdoc.sourceforge.net/htmldoc/various.html#various

Eric Schwabe
+2  A: 

The way that I get around this is to pause Vim with Ctrl+z, play in the terminal, then return to Vim with the command fg.

ptrin
+6  A: 

Check out Conque shell. Lets you run any interactive program inside vim, not just a shell.

redmoskito
This is the coolest thing I have ever seen.
jes5199