Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim - maintain a session in shell by executing commands

vim has a number of ways to execute shell commands from within vim. One can jump to the shell and back to vim using shell, ctrl+z the current process and get back using fg. Selected/Current lines can be executed using !w bash.

However, all these approaches are helpful only for running one command. Once the command executes, the shell is process is killed.

I wanted to know if there is a way to keep executing snippets of code in the shell and have the shell remember functions/variables from the previous command (similar to copying snippets of code to a shell prompt) to debug code. For this the shell session would have to be persisted somehow.

I often run into cases where I need to execute a few functions on the shell and then test them out by calling them. The standard approach would be to copy paste them in a different shell and then execute them. How to do this from within vim?

like image 364
nutsiepully Avatar asked Mar 11 '14 07:03

nutsiepully


1 Answers

If your Vim was build with Python support (most Unix builds are, Windows / Cygwin builds are not), you might want to have a look at the Conque Shell plugin, which allows to run a shell inside a Vim buffer.

Edit: Correction, apparently Vim 7.3 for Windows now also comes with Python support (and thus, Conque compatibility).

like image 173
DevSolar Avatar answered Nov 15 '22 00:11

DevSolar