2

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

3 Answers 3

4

After some research I came up with the following solution:

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

the issue was forcing the % expansion.

1
  • This effectively makes Vim a Python IDE way more powerful. thanks
    – Guillermo
    Mar 28, 2013 at 2:07
0

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.
1
  • 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. Jan 10, 2012 at 9:43
0

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.

You must log in to answer this question.

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