Skip to main content

Documentation 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 has no external dependencies — it requires only Neovim and no additional tools, language servers, or Treesitter parsers. There are two installation variants: Variant 1 lets the plugin register all of its built-in default keymaps for you automatically; Variant 2 gives you full control by letting you wire up only the text objects you want, using the keymap style of your choice.

Variant 1 — Use Default Keymaps

1

Add the plugin to your plugin manager

Install nvim-various-textobjs and enable keymaps.useDefaults in the opts (or config) table. This registers all built-in keymaps from the text object reference table automatically on startup.
{
  "chrisgrieser/nvim-various-textobjs",
  event = "VeryLazy",
  opts = {
    keymaps = {
      useDefaults = true
    },
  },
},
2

Verify the keymaps are active

Open Neovim and run :map iS — you should see the inner subword text object keymap listed. If nothing appears, check that the plugin loaded correctly (e.g. run :Lazy and confirm nvim-various-textobjs is installed and not in an error state).
If you lazy-load the plugin using keys = { ... } (key-event lazy loading), the plugin is not loaded until one of those keys is pressed — which means useDefaults = true cannot register the full keymap table at startup. In that scenario, either switch to event = "VeryLazy" as shown above, or set lazy = false explicitly to force eager loading.
You can also use keymaps.disabledDefaults to disable only specific default keymaps while keeping the rest. For example, disabledDefaults = { "ai", "!" } removes the ai indentation and ! diagnostic keymaps while leaving everything else untouched. See the Configuration page for the full option reference.

Variant 2 — Define Your Own Keymaps

1

Add the plugin with a keys table

Use the keys field in lazy.nvim (or call vim.keymap.set manually in packer/your config) to bind only the text objects you want. Each text object is called as an Ex command for dot-repeat compatibility.
lazy.nvim
{
  "chrisgrieser/nvim-various-textobjs",
  keys = {
    -- define your keymaps here, e.g.:
    { "iS", '<cmd>lua require("various-textobjs").subword("inner")<CR>', mode = { "o", "x" } },
    { "aS", '<cmd>lua require("various-textobjs").subword("outer")<CR>', mode = { "o", "x" } },
  },
},
2

Add keymaps for every text object you need

Each text object function accepts "inner" or "outer" as its argument (where applicable). Text objects without an inner/outer distinction are called with no arguments. Bind them in both operator-pending mode (o) and visual mode (x) so they work after operators and inside visual selections.
-- text object with inner/outer
vim.keymap.set({ "o", "x" }, "iv", '<cmd>lua require("various-textobjs").value("inner")<CR>')
vim.keymap.set({ "o", "x" }, "av", '<cmd>lua require("various-textobjs").value("outer")<CR>')

-- text object without inner/outer
vim.keymap.set({ "o", "x" }, "L", '<cmd>lua require("various-textobjs").url()<CR>')

-- indentation takes two parameters (start border, end border)
vim.keymap.set({ "o", "x" }, "ii", '<cmd>lua require("various-textobjs").indentation("inner", "inner")<CR>')
vim.keymap.set({ "o", "x" }, "ai", '<cmd>lua require("various-textobjs").indentation("outer", "inner")<CR>')
vim.keymap.set({ "o", "x" }, "aI", '<cmd>lua require("various-textobjs").indentation("outer", "outer")<CR>')
3

Consult the Configuration page for further options

Even when managing your own keymaps, you can still call setup() to adjust forward-looking distances, notification behavior, and per-object settings. See the Configuration page for all available options.

Build docs developers (and LLMs) love