Super User is a question and answer site for computer enthusiasts and power users. 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

I am trying to configure vim to run a python script inside a buffer. I tried conqueterm, and I manage to get what I want when I type this command:

:ConqueTerm python -i test.py

Now I want to bind this command to a key to execute the current file/buffer in another buffer. But when I run:

:ConqueTerm python -i %

I get an empty new buffer with nothing displayed. What can I do to execute the script?

I am using gvim 7.3 & python 2.7 on windows 7

share|improve this question
up vote 4 down vote accepted

After some research I came up with the following solution:

map <F8> :exe "ConqueTermVSplit python -i " . expand("%")

the issue was forcing the % expansion.

share|improve this answer
    
This effectively makes Vim a Python IDE way more powerful. thanks – Guillermo Siliceo Trueba Mar 28 '13 at 2:07

Generally use one of the :map command to bind a key to a command.

:map Q :ConqueTerm python -i %^V^M

You can use anything in place of Q, which is similar to the : command. From the VIM help text:

{lhs}   means left-hand-side    *{lhs}*
{rhs}   means right-hand-side   *{rhs}*

:map    {lhs} {rhs}             |mapmode-nvo|           *:map*
:nm[ap] {lhs} {rhs}             |mapmode-n|             *:nm* *:nmap*
:vm[ap] {lhs} {rhs}             |mapmode-v|             *:vm* *:vmap*
:xm[ap] {lhs} {rhs}             |mapmode-x|             *:xm* *:xmap*
:smap   {lhs} {rhs}             |mapmode-s|                   *:smap*
:om[ap] {lhs} {rhs}             |mapmode-o|             *:om* *:omap*
:map!   {lhs} {rhs}             |mapmode-ic|            *:map!*
:im[ap] {lhs} {rhs}             |mapmode-i|             *:im* *:imap*
:lm[ap] {lhs} {rhs}             |mapmode-l|             *:lm* *:lmap*
:cm[ap] {lhs} {rhs}             |mapmode-c|             *:cm* *:cmap*
                    Map the key sequence {lhs} to {rhs} for the modes
                    where the map command applies.  The result, including
                    {rhs}, is then further scanned for mappings.  This
                    allows for nested and recursive use of mappings.
share|improve this answer
    
Thank you for your answer. I know I can use map to make my binding. But the command using % instead of the filename does not work on my computer. It expand correctly in the buffer name, but the ConqueTerm terminal remain silent. – Simon Jan 10 '12 at 9:43

To get the % easily expanded, when entering the command in vim, you may use Ctrl+R and then %. This will expand the % character into command line.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .