An implementation of Vim in Python
pip install pyvim
Issues, questions, wishes, comments, feedback, remarks? Please create a GitHub issue, I appreciate it.
Simply install pyvim
using pip:
pip install pyvim
It is a good idea to add the following to your ~/.bashrc
if you really
want to use it:
alias vi=pyvim export EDITOR=pyvim
The editor is written completely in Python. (There are no C extensions). This makes development a lot faster. It's easy to prototype and integrate new features.
We have already many nice things, for instance:
:set ...
commands have been implemented, like incsearch
,
number
, ignorecase
, wildmenu
, expandtab
, hlsearch
,
ruler
, paste
and tabstop
.vsplit
, tabnew
, only
, badd
, and many
others.Further, when the project develops, it should also become possible to write extensions in Python, and use Python as a scripting language. (Instead of vimscript, for instance.)
We can also do some cool stuff. Like for instance running the editor on the Python asyncio event loop and having other coroutines interact with the editor.
Editing its own source code:
Window layouts (horizontal and vertical splits + tab pages.)
Pyflakes for Python code checking and Jedi for autocompletion:
Other colorschemes:
Chinese and Japanese input (double width characters):
It is possible to create a .pyvimrc
file for a custom configuration.
Have a look at this example: pyvimrc
Compared to Vi Improved, Pyvim is still less powerful in many aspects.
prompt_toolkit
does not (or not yet) allow buffers to have an individual
cursor when buffers are opened in several windows. Currently, this results in
some unexpected behaviour, when a file is displayed in two windows at the
same time. (The cursor could be displayed in the wrong window and other
windows will sometimes scroll along when the cursor moves.) This has to be
fixed in the future.BufferControl
code,
which on every key press tries to reflow the text and calls pygments for
highlighting. And this is Python code looping through single characters.)There is no roadmap. I mostly implement the stuff which I need or interests me, or which gives me the opportunity to learn. But feel free to create a GitHub issue to request a new feature. Pull requests are also welcome. (Maybe create an issue first to discuss it, if you're unsure whether I'll merge it.)
Maybe some day we will have a better data structure (Rope), that makes it possible to open really large files. (With good algorithms, Python does not have to be slower than C code.)
Maybe we will also have line folding and probably block editing. Maybe some day we will have a built-in Python debugger or mouse support. We'll see. :)
There are several reasons.
The main reason is maybe because it was a small step after I created the Python
prompt-toolkit
library. That is a library which is actually only a simply
pure Python readline replacement, but with some nice additions like syntax
highlighting and multiline editing. It was never intended to be a toolkit for
full-screen terminal applications, but at some point I realised that everything
we need for an editor was in there and I liked to challenge its design. So, I
started an editor and the first proof of concept was literally just a few
hundred lines of code, but it was already a working editor.
The creation of pyvim
will make sure that we have a solid architecture for
prompt-toolkit
, but it also aims to demonstrate the flexibility of the
library. When it makes sense, features of pyvim
will move back to
prompt-toolkit
, which in turn also results in a better Python REPL.
(see ptpython, an alternative
REPL.)
Above all, it is really fun to create an editor.
Certainly have a look at the alternatives:
prompt-toolkit
.此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。