side-vim
A Vim mode for PySide6's QPlainTextEdit. Attach it to an existing editor to add
Normal, Insert, Visual and Visual Line modes.
Install
Requires Python 3.12 or newer and PySide6 6.8 or newer. Installing side-vim also installs PySide6-Essentials.
uv add side-vim
Usage
import sys
from PySide6.QtWidgets import QApplication, QLabel, QPlainTextEdit, QVBoxLayout, QWidget
from side_vim import VimMode
app = QApplication(sys.argv)
window = QWidget()
editor = QPlainTextEdit("Try w, i, Esc, v and y.")
status = QLabel()
layout = QVBoxLayout(window)
layout.addWidget(editor)
layout.addWidget(status)
vim = VimMode(editor) # Starts in Normal mode. Qt deletes it with the editor.
status.setText(vim.mode.value)
vim.mode_changed.connect(lambda mode: status.setText(mode.value))
window.resize(800, 500)
window.show()
editor.setFocus()
sys.exit(app.exec())
Attach one VimMode per editor. Import Mode to compare vim.mode with
Mode.NORMAL, Mode.INSERT, Mode.VISUAL or Mode.VISUAL_LINE.
| API | Behavior |
|---|---|
vim.mode_changed.connect(callback) |
Calls callback(mode) when the mode changes. |
vim.pending_changed.connect(callback) |
Calls callback(text) with pending keys such as 2d, or "" when done. Moving the focus to another widget drops pending keys, as a click in another window does in Vim. Switching apps or opening a menu keeps them. |
vim.escape_hook = callback |
Calls callback() before handling Esc. Return True if the app used it, for example to close a popup. |
vim.search_hook = callback |
/ calls callback(True); ? calls callback(False). The app opens its search UI. |
vim.window_hook = callback |
Ctrl+W and one more key call callback(key), such as "h" for Ctrl+W h. The app moves the focus, for example to a panel beside the editor. |
vim.spell_hook = callback |
The spelling commands call callback(command, count), such as ("z=", None) or ("]s", 2). The app shows suggestions, moves the cursor or adds the word. |
vim.set_search("rent", forward=True) |
Saves the search text and jumps to the next match. n repeats in that direction; N reverses it. |
vim.normal() |
Goes to Normal mode as Esc does, from Insert or Visual mode. |
vim.clipboard = True |
Uses the system clipboard for yank, delete, change and paste. Defaults to False. |
vim.layout_map = UKRAINIAN |
Maps Ukrainian letters to Vim keys. This is the default; import UKRAINIAN from side_vim. Set None to disable it, or pass your own dictionary. |
vim.set_enabled(False) |
Restores the plain editor and its cursor. True enables Vim in Normal mode. Read the setting through vim.enabled. |
vim.detach() |
Removes Vim from the editor. To turn it off for a while, use set_enabled(False). |
When the app accepts a search, call set_search with its text and direction,
after normal() if the search was opened from Insert mode.
Search is case-sensitive, wraps around the document, and uses plain text rather
than regular expressions. Each editor keeps its own search. An empty string
clears it. In Insert mode or while disabled, set_search saves the search without
moving the cursor. The demo
shows a find bar and an Esc hook together.
The unnamed register is shared between editors in the same process. With
clipboard=False, yank in one editor and paste in another. With clipboard=True,
text copied in another app pastes as whole lines if it ends in a newline.
Supported keys
Counts work with motions and edits: 3w, 5G, 2dd, y3j. A counted insert
repeats the typed text: 3ix<Esc> inserts xxx.
| Action | Keys |
|---|---|
| Move | h j k l, w b e, W B E, 0 ^ $, gg G |
| Insert | i a I A o O |
| Delete, change, yank | d c y followed by a motion; dd cc yy, x D C |
| Paste, join | p P, J |
| Replace characters | r and a character: 3rx turns three characters into xxx |
| Switch case | ~: 3~ turns abc into ABC and moves past it |
| Undo, redo | u, Ctrl+R |
| Select | v for characters, V for lines; motions extend the selection |
| Edit a selection | d c y x p r ~; o switches its ends |
| Search | / ? through the app hook, then n N |
| Scroll a line | Ctrl+E, Ctrl+Y |
| Scroll half a screen | Ctrl+D, Ctrl+U |
| Scroll a screen | Ctrl+F, Ctrl+B |
| Return to Normal | Esc, Ctrl+[ |
| Window command | Ctrl+W and a key, through the app hook |
| Spelling | z=, ]s [s, zg zG, through the app hook |
In Normal and Visual modes, the Ctrl keys above take priority over app shortcuts.
j and k keep the screen column across tabs and wide characters, and a wrapped
line counts as one line, as in Vim.
After r, Enter puts in a line break, and Ctrl+E or Ctrl+Y copy the
characters below or above. Ctrl+V puts in the next key as it is, or a character
code such as 065 or u20ac. Ctrl+K and two characters put in a
digraph, such as e: for ë. Esc cancels
r. These work as in Vim.
This release has only the keys above. It has no repeat (.), text objects,
f t, g~ gu gU, colon commands, macros, marks, named registers or block
selection.
Differences from Vim
side-vim follows Vim 9.1 with its default settings, except for these:
- Joined emoji and flags, such as 👨👩👧 and 🇺🇦, are one character. Vim splits
them into their parts. Accents, CJK and single emoji work as in Vim, except
that
r Ctrl+Eandr Ctrl+Ycopy an accented letter made of two code points whole. Vim copies it without the accent. - Qt turns a carriage return into a line break, so
rcan't put one in. Vim puts one in forr Ctrl+V Enter, and for Enter afterrin Visual mode. side-vim does nothing there, and Visual mode keeps its selection. - After
r Ctrl+Vand part of a code, such asr Ctrl+V 6, a key with no character, such as an arrow, ends the code. Vim then also runs that key as a command, but side-vim drops it. - Search uses plain text, not regular expressions. There is no command line.
/and?callsearch_hook, then the app shows its own search box and passes the text toset_search. - side-vim has no windows.
Ctrl+Wand the key after it go towindow_hook, and the app decides what they do.Ctrl+W Ctrl+HandCtrl+W Leftarrive ash, as in Vim. It works only in Normal mode, and the hook gets no count. - side-vim has no spell checker.
z=,]s,[s,zgandzGgo tospell_hookwith their count, and the app finds the words and shows the suggestions. They work only in Normal mode.]sand[saren't motions, sod]sdoes nothing. side-vim doesn't havezw,zWorzug. Jputs one space after a period, like Vim withnojoinspaces. Vim's default puts two.- Qt stops scrolling when the last line reaches the bottom of the editor. Vim
scrolls on until the last line is at the top, so
Ctrl+FandCtrl+Estop sooner near the end. The cursor still goes to the line Vim picks. - In Insert mode, Esc and
Ctrl+[go back to Normal mode. Every other key goes to the editor, so arrows, Backspace and app shortcuts work as in any Qt editor. side-vim doesn't have Vim's Insert mode keys, such asCtrl+W,Ctrl+UandCtrl+O. - In Normal and Visual modes, Ctrl keys that side-vim doesn't use go to the
editor or the app, and so do PageUp, PageDown and the function keys.
Ctrl+Aselects all, for example. Qt's keys that change the text do nothing in these modes: paste, cut,Ctrl+BackspaceandCtrl+Delete. In Vim,Ctrl+Vstarts a block selection, which side-vim doesn't have. - In Normal and Visual modes, Alt keys go to the app's shortcuts first, so
Alt+Hcan open a Help menu. gvim does the same withwinaltkeys=menu. side-vim has no Alt keys of its own, so an Alt key that no shortcut uses does nothing. AfterrandCtrl+W, the next key is side-vim's, even with Alt. - Other keys without a command do nothing in Normal mode. They never type text.
- In Normal mode, an Esc with nothing pending goes to the app, so it can close a dialog, for example. Vim does nothing with that Esc except ring its error bell.
- A read-only editor allows movement, scrolling, selection, yank and search, and ignores edits. Vim only warns when you change a read-only file.
- Dragging with the mouse in Normal mode starts Visual mode.
- Outside Insert mode, Ukrainian letters work as the Latin keys in the same
place, so
цisw. Vim needslangmapfor that. Punctuation stays as typed,ґisn't mapped because its key moves between layout variants, and/needs the English layout. The character afterris text, soкцputs in ц, aslangmapdoes in Vim. - On macOS, Ctrl means the physical Control key. Command shortcuts stay with the app.
- The tab width comes from the editor's tab stop, not from a
tabstopsetting. uand the app's undo share the editor's undo stack, so they undo the same steps.
Develop
uv sync --locked
make run # Demo window
make check # Ruff and pytest
make format # Format Python
make record # Record expected results using local Vim
make unicode # Regenerate Vim character classes and widths
make digraphs # Regenerate Vim digraphs
make mac-keys # Key checks on a Mac
Tests run Qt offscreen. CI runs for release tags and can also be started from Actions → CI → Run workflow. It tests Linux, macOS and Windows on Python 3.12 and 3.14, and the lowest allowed PySide6 on Python 3.12. The tests replay saved Vim cases, so CI doesn't need Vim. Recording them needs Vim, and the scrolling cases need a Unix terminal.
On a Mac, make mac-keys opens the demo and presses keys through macOS. It checks
Ctrl and Cmd keys, search, read-only mode and the Ukrainian layout, and prints PASS
or FAIL for each. Start it on the English (ABC) layout with Ukrainian-PC installed,
and don't type until it finishes.
Release
Set these up by hand before the first tag:
-
In the GitHub repository, open Settings, then Environments, and create
pypi. Add yourself as a required reviewer. Leave Prevent self-review off, so you can approve runs you start. Limit deployment tags tov*. -
In your PyPI account's Publishing page, add a pending trusted publisher:
Field Value PyPI project side-vimGitHub owner sprytnykRepository side-vimWorkflow release.ymlEnvironment pypiA pending publisher creates the project on its first upload. No PyPI token goes into GitHub. See the PyPI setup guide and GitHub approval guide.
The project release skill has the command sequence and approval points.
Metadata
Release files for side-vim 0.2.1
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 |
|---|---|---|---|---|
| side_vim-0.2.1.tar.gz | 70.1 kB | With provenance | Details for side_vim-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| side_vim-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for side_vim-0.2.1-py3-none-any.whl |
Total release size: 143.4 kB
Release files / side_vim-0.2.1.tar.gz
| Download URL | side_vim-0.2.1.tar.gz |
|---|---|
| Size | 70.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7cfc94830475b64bece229dc3cd408079d5ed779e30065174634937ac8b5947
|
|
BLAKE2b-256 checksum How to use checksums |
620ffb7f90e51792730a403ea6f4ec30659389b0e9042ac766c1c6761964e1a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logRelease files / side_vim-0.2.1-py3-none-any.whl
| Download URL | side_vim-0.2.1-py3-none-any.whl |
|---|---|
| Size | 73.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cffff712e933c232d96e00b2631f705c195d5fbfd21cd1030733b95769c448ee
|
|
BLAKE2b-256 checksum How to use checksums |
3e4de61a8ea3280a19d3607c30c4219da5d6d7a3df39a2543a9918aff9d4ac90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logSecurity for side-vim 0.2.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for side_vim-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logA 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.