Shell commands from vim

12,407

Solution 1

You can start a shell from Vim using the :sh command. When the shell exits (after the exit command or Ctrl+D) you return to Vim. The name for the shell command comes from the shell option.

For terminal Vim (on unix-like systems) you can also use Ctrl+Z to suspend Vim and get back to the shell from which it was run. To resume the Vim process, use the fg command.

Solution 2

I know this is a bit late, but my preferred approach is suspending the vim process (Ctrl+z). You return to your shell/bash command prompt.

Then execute whatever command(s) you like.

Return to vim by typing fg

Share:
12,407
xralf
Author by

xralf

Updated on June 11, 2022

Comments

  • xralf
    xralf 3 months

    What is the best approach of using shell commands from vim? I know about the possibility of !shell_command. But this doesn't know all commands e.g. export OSTYPE; make install So I have to run it outside vim. Is there better approach?

  • xralf
    xralf over 11 years
    Is it possible to have shell in one split or tab and file in another? I sometimes need to see shell and source file at the same time. I'm using tmux but that's bad to mix tmux command and vim commands for navigation between splits.
  • ZyX
    ZyX over 11 years
    @xralf You can try Conque. It is slow, does not work well with unicode and won't update buffer that is not in current window (until you switch to it), but that is the best you can do with current vim capabilities. You may also try screen plugin which can send keystrokes to other screen/tmux window from within vim.