Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From time to time I want to use vim as scratch pad for commands that I would like to send to a command line shell like psql (Postgres), ghci (Haskell programming language), octave ('calculator'), gnuplot (plot) etc.

The advantages would be that you could put comments next to command lines, directly document your session, incrementally develop command lines, test examples ad-hoc in manuals etc.

Pro features I would like to use: send a selection to a shell, send e.g. the next 10 lines to a shell, display the output of a shell command into a vim output buffer, into a vim yank-register, directly insert it etc.

There should be some support of a shell-session concept, i.e. the shell should not be started for each command from scratch.

I could live with a kind of remote controlled xterm which I would put side by side to a vim window.

share|improve this question
A bonus tip: bash supports vi-keybindings with set -o vi which enables more advanced editing of the command line. – user13742 Sep 20 '12 at 19:14
@htor, yup, this is also useful, but it is really a different use case (btw. setting set editing-mode vi in ~/.inputrc gives you that experience in all readline enabled applications). – maxschlepzig Sep 20 '12 at 19:30
And btw, Ctrl-X Ctrl-E in Bash opens your $EDITOR with the current command, so you can edit it as you like. The command will be run when you quit the editor. – Axel Knauf Sep 21 '12 at 14:51
@AxelKnauf Ctrl-X Ctrl-E ... it is ESC v ! ;) – maxschlepzig Sep 21 '12 at 18:20
up vote 2 down vote accepted

Try vim-slime, an environment inspired by Emacs's SLIME mode. It sends the contents of Vim to a screen or tmux session.

In the future you can probably also use Xiki, but for now its Vim support is incomplete.

share|improve this answer
vim-slime is great - C-c-c sends the current paragraph to the specified screen-window (screen is used by default). I'd like to configure a key-binding for just sending the current line - probably not that hard. – maxschlepzig Sep 26 '12 at 5:20

maxschlepzig: This is an old thread but I hope it may be still useful to provide info that I just learnt about vim-slime. You can configure the following keybinding (F2 in this case) in .vimrc to send current line.

vmap <F2> :SlimeSend<CR>

nmap <F2> :SlimeSend<CR>

F2 can be replaced by any other key.

share|improve this answer
you should add a link to the manual or tutorial for vim-slime for those who don't know what it is. Also include a snippet of why this is useful or a short example. Both will make this answer much more popular. – user1794469 Jul 16 '15 at 15:22

Your Answer


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.