vith (วิธ) — a fork of pyvim
vith (Thai: วิธ, from วิธี / Pali-Skt vidhi, "method"; also a portmanteau of ViM + THAi) is a fork of pyvim — "an implementation of Vim in Python" originally created by Jonathan Slenders.
The upstream project was idle for several years, so this fork continues development independently. It adds Thai & Lao script support (terminal cell-cluster navigation and editing, two-tier word segmentation, SARA AM differential rendering), live async :render split previews (real-time formatted Markdown, reStructuredText, JSON, CSV/TSV, and ANSI rendering with heading-anchored scroll sync), and speed / latency / modern-Python stability work (streamed + cached Pygments highlighting, lazy colorscheme loading, O(1) pyflakes error index, Python 3.14+/3.15 asyncio startup fix).
Full credit and history are preserved: Jonathan Slenders' original changelog is retained verbatim in the CHANGELOG appendix, and the BSD 3-clause license is retained with stacked copyright.
This fork is published as a separate PyPI package (vith) and is not a drop-in replacement for pyvim.
Requirements
This fork runs on Python 3.10+ (prompt_toolkit 3.0) and adds four major, machine-verified subsystems (documented in the docs/ Open Knowledge bundle):
- Thai & Lao script support: terminal cell-cluster navigation and editing (
h,l,j,k,x,X,s,r,~,$,e...), two-tier Thai word segmentation (libthaiwith an always-available orthographic fallback) and SARA AM (U+0E33/U+0EB3) differential renderer fixes. Seedocs/thai_support_plan.md. - Speed, latency & modern-Python stability: streamed + cached Pygments highlighting, per-line word-span caches for Thai word motions, lazy colorscheme loading, cached word completion, an O(1) pyflakes error index, and the Python 3.14+/3.15
asynciostartup-crash fix. Seedocs/speed_latency_plan.md. - Ex command completeness &
:setparity: full Vim Ex command set across files (:r/:readincl.:r !cmd,:sav,:up,:x,:wa,:xa,:so,:f,:enew), buffers/windows/tabs (:ls,:b #,:bf/:bl,:sb,:bd <target>,:clo,:on,:tabo/:tabm/:tabs), generalized range editing (:$/±N,:d,:y,:pu,:m,:t/:co,:j,:sort,:retab,:g/:v,:[range]!cmd,:[range]wpartial/append/pipe,:[range]norm[!]),%/#filename expansion with:p/:h/:t/:r/:e, in-editor read-only info splits (:ver,:mes,:reg,:marks,:set), and ergonomic:setsyntax (?,!,inv, multi-arg,smartcase,shiftwidth,readonly,autoindent,fileencoding,fileformat). Seedocs/command_completeness_plan.md. - Live async
:rendersplit preview: real-time non-blocking split preview (:render,:render-split-v,:render-split-h) powered by optionalvith[render](rich+rich-rst), with directSegment→StyleAndTextTuplesbridging, debounced executor rendering, stale-edit fallback, heading/landmark-anchored scroll sync, and pluggable[render.commands]CLI renderers. Seedocs/live_render.md.
All changes are audited in docs/bugs/ (194 machine-verified findings across 14 audit rounds and 4 addenda — 193 fixed, 1 archived/withdrawn); quality is enforced with pytest (562 tests), mypy and ruff.
Issues, questions, wishes, comments, feedback, remarks? Please create a GitHub issue, I appreciate it.
Installation
Simply install vith using pip:
pip install vith
For Python autocompletion support (via Jedi):
pip install "vith[jedi]"
For live async :render split preview (Markdown, reStructuredText, JSON, CSV/TSV via Rich):
pip install "vith[render]"
It is a good idea to add the following to your ~/.bashrc if you really want to use it:
alias vi=vith
export EDITOR=vith
The good things
The editor is written completely in Python. (There are no compiled editor extensions; on Python < 3.14 the default zstd cold-text backend uses the zstandard package.) This makes development a lot faster. It's easy to prototype and integrate new features.
We have already many nice things, for instance:
- Syntax highlighting of files, using the Pygments lexers.
- Horizontal and vertical splits, as well as tab pages. (Similar to Vim.)
- All of the functionality of prompt_toolkit. This includes a lot of Vi key bindings, it's platform independent and runs every Python version covered by
python_requires >= 3.10. - Thai/Lao input files: cell-cluster safe navigation and syntax-aware word segmentation, including dictionary segmentation when
libthaiis installed — with visual mode, visual-block editing (C-vhighlight/y/d/I/Aand blockp/P),{count}|, andj/kstaying on the visual display column across combining marks, CJK, and customtabstops, all cluster-aligned on Thai/Lao text. - Compressed undo/redo history: cold snapshots are stored with quez (Zstandard level 1 by default), configurable via
cold_text_compressioninconfig.toml(or.vithrc) and inspectable with:compression. - Comprehensive
:set/:setlocaloptions with bare:set,:set all, queries (opt?), toggles (opt!,invopt), multi-argument commands (:set nu rnu ts=4 et), and live preview:number/relativenumber,hlsearch,incsearch,ignorecase,smartcase,expandtab,autoindent,tabstop,shiftwidth,readonly,fileencoding/fenc,fileformat/ff,filetype/ft,scrolloff,colorcolumn,cursorline/cursorcolumn,wrap/breakindent,list,paste,ruler,wildmenu,mouse,jedi, andtildeop. - Rich Vim-style Ex commands:
:e,:enew,:r/:read(file&!cmd),:w/:w!(incl. range,>>append,!cmdpipe),:sav/:saveas,:up,:x/:xa/:wa/:wq/:wqa/:q/:qa/:cq(plusZZ/ZQ),:so/:source,:f/:file,%/#filename expansion with:p/:h/:t/:r/:e,:ls/:b(names, 1-based indices,#alternate),:bn/:bp/:bf/:bl/:bd/:sb,:sp/:vsp/:clo/:on,:tabe/:tabc/:tabo/:tabn/:tabp/:tabfir/:tabl/:tabm/:tabs,:u/:undo,:red/:redo,:noh, generalized range editing (:$/±N,:s,:g/:v,:d,:y,:pu,:m,:t/:co,:j,:sort,:retab,:[range]!cmd,:[range]norm[!]), live async preview splits (:render,:render-split-v,:render-split-hwith optionalvith[render]), and in-editor inspection splits (:reg,:marks,:mes,:ver,:compression,:help). Auto completion for Python source code uses Jedi, and code checking runs asynchronously via Pyflakes. - Live async
:rendersplit preview: split the current buffer vertically (:render-split-v), horizontally (:render-split-h), or with your configured default (:render) to preview formatted text in real time without lagging the editor. Powered by the optionalvith[render]extra (rich+rich-rst, zero startup overhead when unused), rendering runs asynchronously off the main thread with debounce/coalescing and supports Markdown (headings, bold/italic/underline, tables, Pygments fenced code blocks, Thai/Lao text), reStructuredText, pretty-printed JSON (retaining the last valid render with astaleindicator while mid-edit), CSV/TSV tables, ANSI escape logs, and custom CLI renderers via[render.commands]. Preview cursor and scroll position stay synchronized with the editor via heading/landmark anchors and automatically pause when you focus the preview pane to scroll or yank (/search andv/ywork inside the preview). Close anytime with:render!,:q, or:only. - Colorschemes can be changed at runtime.
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.
Live :render Split Preview
Install the optional render extra to enable built-in Rich & reStructuredText rendering:
pip install "vith[render]"
| Command | Action |
|---|---|
:render |
Open/refresh live preview using [render].default_split (vertical by default) |
:render-split-v |
Open (or re-orient) a vertical split preview on the right while keeping editor focus |
:render-split-h |
Open (or re-orient) a horizontal split preview on the bottom while keeping editor focus |
:render! / :render-split-v! / :render-split-h! |
Close the active buffer's live preview split (standard :q / :only also clean up automatically) |
You can customize behavior and wire external CLI formatters (receiving the buffer on stdin with COLUMNS set to the preview pane width and emitting ANSI-styled text on stdout) in ~/.config/vith/config.toml:
[render]
default_split = "vertical" # "vertical" or "horizontal"
debounce_ms = 150 # debounce delay before background re-render
sync_scroll = true # heading/landmark-anchored cursor & scroll sync
[render.commands]
# Optional per-filetype external renderers (e.g. HTML via lynx/w3m, or glow)
# html = "lynx -dump -stdin"
For full technical details (architecture, Rich-to-prompt_toolkit style bridging, async coalescing, heading-anchored scroll sync, and latency benchmarks), see docs/live_render.md.
Configuring vith
Vith uses a declarative TOML configuration file loaded from ~/.config/vith/config.toml (or ~/.vithrc). Advanced Python callbacks and keybindings can be placed in ~/.config/vith/hooks/ and registered under [hooks].
Wide-emoji note: terminals that widen emoji presentation (Kitty, Alacritty, szn with variation-selector-always-wide on) render some narrow bases followed by U+FE0F (e.g. ❤️) as 2 cells. Set variation_selector_always_wide = true under [editor] in config.toml (or :set variation_selector_always_wide) so vith counts them as 2 cells and keeps cursor, wrapping, and block selection aligned.
Have a look at these examples:
- TOML configuration:
config.toml - Modular Python hook:
build-and-run.py - Legacy Python
.vithrc:vithrc
Limitations
Compared to Vi Improved, Vith is still less powerful in many aspects.
prompt_toolkitdoes 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.- The data structure for a buffer relies directly on
prompt_toolkit's string buffer (Document.text). This works well for normal-sized files and keeps the editor fast and simple, though very large files will experience keystroke latency due to whole-string copies. - A lot of nice Vim features, like line folding, macros, etcetera are not yet implemented.
- Windows support is not that nice. It works, but could be improved.
Roadmap
Pull requests and issues are welcome. Feel free to create a GitHub issue to discuss ideas or report problems.
Visual-block editing (C-v) is available — highlights, yanks, cuts, inserts, and block pastes are cell-cluster and tab-stop safe on Thai/Lao text (including SARA AM, custom tabstops, and multi-line visual blocks) — and basic mouse support can be toggled with :set mouse. Maybe next: line folding, text-area registers UI, and a built-in Python debugger instead of the current !python3 %-style runs. We'll see. :)
Testing
To run all tests, install the optional and development dependencies (pytest, pytest-cov, pytest-xdist, mypy, ruff):
pip install -e ".[jedi,lzo,render,dev]"
Run unit tests via the test runner script (executes all 562 tests in parallel and enforces ≥85% test coverage):
bash scripts/runtest.sh
Or run pytest directly from the root vith directory:
python -m pytest tests
Developer helper scripts are provided in scripts/:
scripts/runtest.sh: run the full test suite in parallel with coverage enforcement (562 tests)scripts/type-check.sh: runmypy .(typing, 88 source files checked against the 3.10 floor)scripts/lint-check-and-fix.sh: runruff check --fix .(linting)scripts/code-format.sh: runruff format(formatting)
The reproducible measurements quoted in the docs come from:
python tools/bench_plans.py
Why was PyVim originally created?
(From Jonathan Slenders' original PyVim documentation):
"The main reason is maybe because it was a small step after I created the Python
prompt-toolkitlibrary. 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
pyvimwill make sure that we have a solid architecture forprompt-toolkit, but it also aims to demonstrate the flexibility of the library. When it makes sense, features ofpyvimwill move back toprompt-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."
Why was the Vith fork created?
Upstream pyvim has been idle for several years. Vith was created to bring modern Python support and first-class Southeast Asian language capabilities to terminal-based editing:
- Thai & Lao cell-cluster editing: character-wise motions (
h,l,x,s,r,~...) treat combining sequences as indivisible display cells, preventing dangling accents or cursor misalignment. - Syntax-aware word segmentation: two-tier word boundaries combining dictionary lookup (
libthai) with an orthographic cluster fallback. - Differential rendering fixes: terminal diff-renderer updates for
SARA AM(U+0E33/U+0EB3) and right-margin combining marks. - Performance & latency: streamed Pygments syntax lexing, deferred colorscheme compilation, singleton word-completion caches, and an O(1) pyflakes error index.
- Modern Python stability: clean startup on Python 3.14+/3.15 asyncio event loops, PEP 621 packaging, and complete type annotations.
The Thai/Lao design is adapted from szn, a Zig terminal multiplexer with first-class Thai/Lao handling. szn separates terminal cell clusters (a base character plus its combining marks) from Thai syllables/words; vith follows the same split, so h/l step one visual cell while w/b/e step one Thai syllable or dictionary word. vith also carries over szn's SARA AM rule for differential rendering: when ำ/ຳ or its preceding consonant changes, both shaped cells are repainted. For the broader cell/grapheme and line-breaking rationale, see Text Reflow in szn.
Alternatives
Certainly have a look at the alternatives:
Thanks
- To Jonathan Slenders, for creating PyVim and prompt_toolkit.
- To Vi Improved, by Bram Moolenaar, for the inspiration.
- To Pygments, Jedi, pyflakes, docopt, quez, and Rich / rich-rst (optional
:renderextra). - To the Python wcwidth port of Jeff Quast for support of double width characters.
- To Guido van Rossum, for creating Python.
Metadata
Release files for vith 0.16.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vith-0.16.5.tar.gz | 293.2 kB | Without provenance | Details for vith-0.16.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vith-0.16.5-py3-none-any.whl | Python 3 | none | any | Details for vith-0.16.5-py3-none-any.whl |
Total release size: 481.6 kB
Release files / vith-0.16.5.tar.gz
| Download URL | vith-0.16.5.tar.gz |
|---|---|
| Size | 293.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cccc9a07c1366431d13c69c4a39c0683c5c0bf78cb4286870642d7be2b45a858
|
|
BLAKE2b-256 checksum How to use checksums |
58f2260cab95725d7de8ab311a9f1df9de8f3db779f8af9ef7eeb04d601f557e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.14.10 Darwin/27.2.0
|
Release files / vith-0.16.5-py3-none-any.whl
| Download URL | vith-0.16.5-py3-none-any.whl |
|---|---|
| Size | 188.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71c04f8f1464abece3c4ce41fa063c817e82366a877ab945099e7e937435000e
|
|
BLAKE2b-256 checksum How to use checksums |
067dfa97372fecff1e9b877b00f57296daa22372444971c994f2876dea06803b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.14.10 Darwin/27.2.0
|
Security for vith 0.16.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.