Friendly Python interface for interacting with Vim.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file vimlib-0.0.13.tar.gz
.
File metadata
- Download URL: vimlib-0.0.13.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b7a0bbe93e6fa0f53b4a54aa6b3b9554efe50e22ba353648323040e839b4b15 |
|
MD5 | a36524671af216f7655bc3af3191da95 |
|
BLAKE2b-256 | 4ca20338e7b9a5832bde23164aecaf99badc4c6d8020e40a3b1638fe92457ae2 |
File details
Details for the file vimlib-0.0.13-py3-none-any.whl
.
File metadata
- Download URL: vimlib-0.0.13-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19f6ff09f2a05345b99f84a934c128e54fada10de5496df72536a4431eb91865 |
|
MD5 | 2ff7536b238befcddd3b7d8302a7c8bc |
|
BLAKE2b-256 | 0650a3ae96380d2358072bb525d527fed95228d8c1be748e44fa127bd493b73c |