ipdb works fine in the shell, but I want to debug under vim, after I set ipdb.set_trace(), and then !python %,
the console below gives me this messy prompt, any idea?
4 Answers
I guess you are using a GUI Vim. GVim? MacVim? The pseudo terminal you get when executing external tools is not, has never been and will probably never be able to understand the escape characters you see. That means no color and no ncurses-style widgets.
You'd better run it in a separate terminal or find a way to disable colors in iPython.
5 Comments
:set colorshell". I'm really curious about your solution. I remember googling a bit about that subject 2 years ago without any success.If you don’t really want to patch vim as well as run in a separate terminal as @romainl suggests then there is Conque plugin which provides a way to have colored pseudo-terminal in a vim buffer. You have to run
ConqueTerm(|[V]Split|Tab) sh
and within it run
python path/to/file.py
(no % is possible) though. It can be narrowed down to a mapping:
nnoremap <expr> ,p ":\<C-u>ConqueTermVSplit sh\n\<C-o>:call feedkeys('python '.shellescape(bufname(".bufnr("%").")).\"\\n\")\n"
Comments
I have created my own workaround for this which may be valuable to you depending on how you use ipdb. The idea is that you can pass in no_colors=True to set_trace() and that way the interactive debugger will not produce any colour output. I have also enabled this argument for launch_ipdb_on_exception.
This means that you can do:
import ipdb
ipdb.set_trace(no_colors=True)
And the output looks fine in MacVim.
To use this you will have to use my version of ipdb, which is here, actual relevant commit if you want to see what I did is here.
It turns out that ipdb is merely a convient way of accessing ipython.core.debugger, Pdb the actual debugger is defined there.
Comments
For windows users i suggest ConEmu. Works perfectly with ipdb (highlighting, auto-complete, ...)