Skip to main content

pre-commit Code style: black

PyPI PyPI - Python Version PyPI - License

Read the Docs

A friendly interface for interacting with Vim using Python.

Installation

pip install vimlib

Recommended: Using your chosen virtual environment, that's been setup for Vim, or Neovim, to use, install vimlib using that.

Examples:

  • ~/vimfiles/.venv/bin/pip.exe install --upgrade vimlib
  • cd ~/vimfiles && poetry install vimlib

Usage

Current

vimlib offers a convenient way to interact with the current environment, much like Vim's built-in current object.

from pyvim import current

Echo

vimlib offers a convenient way to print to Vim's stdout in a colorful, and flexible, manner.

import pyvim


# Print to STDOUT
pyvim.echo("Hello!")
# Print with chosen highlight group
pyvim.echo("Hello!", "PyVimSuccess")  # Built-In Green
pyvim.echo("Hello!", "PyVimCaution")  # Built-In Yellow
pyvim.echo("Hello!", "PyVimDanger")   # Built-In Red

Highlight Groups

vimlib offers a convenient way to interact with highlight groups.

from pyvim import current


# Boolean. Check if a highlight group is available
has_highlight = 'MyHighlightGroup' in pyvim.current.highlights

Visual Selection

vimlib offers a convenient way to interact with highlighted text. Also highlights the most recent highlighted text.

from pyvim import current


# String with the current, or last, selection.
# Support basic, linewise, and block visual highlights
selection = pyvim.current.selection

Utilities

vimlib offers convenient utilities.

System Commands

Note: Chaining will stack <CR> and other tokens.

from pyvim.utilities import wrap_vim_command


wrapped_command: str = wrap_vim_command(
    command="!py %",
    silent=True,
    clear=True,
)

print(wrapped_command)
# ":<C-U>silent !py %<CR>

Examples

>>> print(wrap_vim_command('w'))
:<C-u>w<CR>
>>> print(wrap_vim_command('w!', silent=True))
:<C-u>silent w!<CR>

Mappings

vimlib offers a convenient way to interact Vim mappings.

>>> import pyvim
>>>
>>>
>>> # Set <Leader>r to write current buffer to disk.
>>> # Equivalent to `:nmap <Leader>r :<C-u>silent w<CR>` in Vim.
>>> set_mapping('nmap', '<Leader>r', ':<C-u>silent w<CR>')

Function

WARNING: Non-Working

vimlib offers a convenient way to interact Vim functions.

import pyvim


vim_function = pyvim.Function(
    name="Foo",
    arguments=None,
    optional_arguments=True,
    overwrite=True,
)

result = vim_function(...)

Job

WARNING: Non-Working

vimlib offers a convenient way to interact Vim jobs and channels.

import pyvim


vim_job = pyvim.Job(
    cmd='python -m http.server',
)

vim_job.stop()
vim_job.status

Registers

vimlib offers a convenient way to interact Vim registers.

>>> import pyvim.Register

Metadata

Release files for vimlib 0.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vimlib 0.0.13
File Size Uploaded Provenance Actions
vimlib-0.0.13.tar.gz 10.8 kB Without provenance Details for vimlib-0.0.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vimlib 0.0.13
File Interpreter ABI Platform Actions
vimlib-0.0.13-py3-none-any.whl Python 3 none any Details for vimlib-0.0.13-py3-none-any.whl

Total release size: 21.9 kB

Release files / vimlib-0.0.13.tar.gz

Download URL vimlib-0.0.13.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2b7a0bbe93e6fa0f53b4a54aa6b3b9554efe50e22ba353648323040e839b4b15
BLAKE2b-256 checksum
How to use checksums
4ca20338e7b9a5832bde23164aecaf99badc4c6d8020e40a3b1638fe92457ae2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.1

Release files / vimlib-0.0.13-py3-none-any.whl

Download URL vimlib-0.0.13-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19f6ff09f2a05345b99f84a934c128e54fada10de5496df72536a4431eb91865
BLAKE2b-256 checksum
How to use checksums
0650a3ae96380d2358072bb525d527fed95228d8c1be748e44fa127bd493b73c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.1

Security for vimlib 0.0.13

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page