PyInteractive


Ⅰ. 插件描述

This plugin is a simple realization of read-eval-print loop for Python in Vim command window.

Ⅱ. 基本信息

创建日期:  2010-09-08
使用用户:  1
Github星:  7
插件作者:  Almaz Karimov

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'clericj/pyinteractive'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'clericj/pyinteractive'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'clericj/pyinteractive'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/clericj/pyinteractive-vim

Ⅳ. 文档说明

This plugin is a simple realization of read-eval-print loop for Python in Vim command window. It requires Python support (see +python) and at least version 2.6 of Python interpreter (you can check python version by running :py import sys; print(sys.version) ).

Features:

  • auto-completion (tab)
  • auto-indent
  • keeps your recent results in the result history, for later user.
  • IPython-like magic operators (e.g. object?)
  • evaluate selected code
  • and more (see the pyinteractive documentation for details)

Demonstration (ver 0.5): http://www.youtube.com/watch?v=oy9Cv3eKy-0&feature=plcp
Project home: https://github.com/clericJ/pyinteractive-vim

Commands:

:PyInteractiveREPL
     Opens an interactive Python console in vim. If you want to finish working with the interpreter,
      press <esc>. Interpreter states are saved between PyInteractive sessions (but not between vim
     sessions), so that if you use PyInteractiveREPL, type x=1 here, close it and then reopen again,
     variable x will still have value 1.

  :PyInteractiveHistory [options]
      Echoes session history.
      Possible options:
           -r          Print history without any formatting (mnemonic: raw)
           -i          Print only input history (mnemonic: input)
           -o          Print only output history (mnemonic: output)
           -f {FILE}   Write history to file {FILE}

:PyInteractiveEval {code}
    Evaluate given code in the interpreter. Command is useful for quickly testing results
    and for scripting purposes (for example, in context menu). Example:
            :PyInteractiveEval def inc(x): return x+1
            :PyInteractiveEval inc(1)
            2
            :PyInteractiveREPL
            >>> inc(10)
            11

  :PyInteractiveRunBuffer
      Execute current buffer in python interpreter and show result.

Autocompletion is defined for PyInteractiveEval command and for input() opened by PyInteractiveREPL command and can be accessed by pressing <tab> key (default, see wildchar if you want to change this).

Examples:

:PyInteractiveREPL

def inc_10(x):

...     return x+10
...

inc_10(7)

17

  import sys
sys.ex<tab> # codecompletion (see pyinteractive-autocompletion)

<built-in function exit>

<ESC>

:PyInteractiveEval inc_10(11) +1
22
:PyInteractiveHistory
in[1]: def inc_10(x):
in[2]:     return x+10
in[3]:
in[4]: inc_10(7)
out[1]: 17
in[5]: import sys
in[6]: sys.exit
out[2]: <built-in function exit>
in[7]: inc_10(11) +1
out[3]: 22

添加新评论