Python Interpreter Shell with Vi(m) integration possible?

前端 未结 2 1278
清歌不尽
清歌不尽 2021-02-05 16:19

I love to use bpython but in Ruby there is a gem called interactive_editor that makes it possible to combine Vi(m) with the Ruby shell which makes the Development process much m

2条回答
  •  天命终不由人
    2021-02-05 16:42

    I couldn't get vim-ipython to work, so I made this .vimrc solution that works with ConqueShell:

    imap  m Vyp
    nmap  m Vyp
    vmap  m yp
    imap  n ']0j
    nmap  n ']0j
    

    From a new Vim screen and ConqueShell installed, type :ConqueTermSplit python. Now return to the original window (the shortcut is ) and type in some Python code.

    To send the line under to cursor to the interpreter, press m. I have the leader mapped to comma, so that's a pretty simple motion. To send a block of code, highlight some lines in visual mode and do m. It works the same way.

    To return to your script, n goes to the line immediately following what you just executed. As a side benefit, you can also use this command to move from window to window quickly.

    EDIT (2-20-2015): If you're using ipython as the interpreter, you need to run %autoindent to turn off auto-indenting to preserve formatting for some code blocks. Cheers!

提交回复
热议问题