Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

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
up vote 3 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

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

Your Answer

 
discard

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.