The Lua API exposed byDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/chrisgrieser/nvim-various-textobjs/llms.txt
Use this file to discover all available pages before exploring further.
nvim-various-textobjs makes it possible to build editor utilities that go well beyond simple operator + text object pairings. Each recipe below is a self-contained keymap you can drop directly into your Neovim config. They all rely on the same core pattern: call a text object function, check whether Neovim switched to visual mode, and then act on the selection.
Smarter gx — forward-seeking URL opener
Neovim’s built-in gx only opens a URL when the cursor is sitting on it. This version uses the url() text object, which seeks forward to the next URL within the configured look-ahead distance, so you can trigger it from anywhere on the line (or even lines before the URL).
Forward-seeking gf — filepath opener
The same forward-seeking pattern applies to filepaths. This version of gf selects the nearest filepath ahead of the cursor, checks whether it exists on disk, and opens it — or warns you if the path cannot be resolved.
Both
gx and gf use vim.fn.getregion to extract the selected text. This function requires Neovim 0.10 or later.dsi — Delete surrounding indentation
A common refactoring task is to remove a conditional or loop wrapper while keeping its body. This command selects the outer indentation block, dedents the content, then deletes the two surrounding border lines. The mnemonic mirrors ds from vim-surround — Delete Surrounding Indentation.
print line:
ysii — Yank surrounding indentation borders
Sometimes you need just the two border lines of an indented block — not the content itself. This command yanks them into the + register and briefly highlights them so you have visual confirmation. The cursor is restored to where it started, making the operation feel non-destructive.
Indent last paste (P)
In indentation-sensitive languages like Python, pasting code often results in incorrect indentation that an auto-formatter cannot safely fix without semantic understanding. Mapping P to select the last change (the paste) and immediately indent it solves this ergonomically. The mnemonic is “shift paste.”
ii / entireBuffer hybrid
When ii (inner indentation) is invoked on a line with zero indentation, the plugin warns that no indented block was found. This hybrid replaces that warning with a fallback to entireBuffer, selecting the whole file instead — useful if you treat ii as a general “select the current block” command.
Go to next number
Because text objects switch to visual mode when they find a match, you can immediately exit visual mode to create a pure motion: the cursor ends up at the start of the found object without any selection remaining. This gives you a “go to next number” motion without needing a separate motion plugin.This pattern works best for characterwise objects with predictable forward-seeking behaviour. For subwords and similar word-segment objects, a dedicated motion plugin like nvim-spider will be more reliable, since
nvim-various-textobjs is primarily designed as a text object library rather than a motion library.