Katsu
Katsu

Reputation: 1958

vim map command ipython

I'm trying to map a function which launch ipython qtconsole and next IPython from https://github.com/ivanov/vim-ipython.

What I did is:

map <key> :!ipython qtconsole&:IPython<CR>

When I press <key> on vim, it works well but messages from ipython console are displayed on vim editor so that I can't see my code.

So I tried :

nnoremap <silent> <key> :!ipython qtconsole&:IPython<CR>

But nothing changed.

Here are the displayed messages from ipython:

[IPKernelApp] To connect another client to this kernel, use:
[IPKernelApp] --existing kernel-4812.json
void DBusMenuExporterPrivate::addAction(QAction*, int): Already tracking action "%%!" under id 54 
void DBusMenuExporterPrivate::addAction(QAction*, int): Already tracking action "%%capture" under id 56 
void DBusMenuExporterPrivate::addAction(QAction*, int): Already tracking action "%%timeit" under id 57 
...

Any idea?

Upvotes: 0

Views: 300

Answers (2)

Katsu
Katsu

Reputation: 1958

I finally comed up with something which works. For those who are interested in launching vim-ipython by pressing on key here is way to do that. So in .vimrc I added the following functions:

function! ViPy()
    call system('ipython qtconsole &>/dev/null &')
    :sleep 500m "400m not enough so ...
    :py km_from_string("*") "same as :IPython
endfunction

Here is the key mapped:

map <F12> :call ViPy()<CR>

May be there is a better way to do that. Thank's to post it.

Upvotes: 0

ZyX
ZyX

Reputation: 53674

You may silence ipython by either using &>/dev/null (before &) or using system() in place of a bang: :call system('ipython qtconsole&')|IPython.

I guess you will need sleep command before :IPython for ipython to have a chance to start though.

You have another issue here: :!ipython qtconsole&:IPython launches ipython with qtconsole argument and tries to run command :IPython in a separate thread in a shell. Obviously shell does not know anything about vim commands. Replace & with &<CR>.

Upvotes: 1

Related Questions