-
Notifications
You must be signed in to change notification settings - Fork 0
Simple python read-eval-print loop inside Vim
vim-scripts/PyInteractive
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a mirror of http://www.vim.org/scripts/script.php?script_id=3231 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
About
Simple python read-eval-print loop inside Vim