Indentation text objects select blocks of lines that share the same or deeper indentation level relative to the cursor line. They are particularly useful for languages like Python, YAML, and Lua where indentation conveys structure, letting you yank, delete, indent, or operate on entire logical blocks without needing Treesitter or language-specific support.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.
indentation
Function: indentation(startBorder, endBorder)
Both parameters accept "inner" or "outer" independently, giving fine-grained control over which border lines are included in the selection:
startBorder = "inner"— excludes the line above the indented block (the “opening” border)startBorder = "outer"— includes the line above the indented blockendBorder = "inner"— excludes the line below the indented block (the “closing” border)endBorder = "outer"— includes the line below the indented block
| Keymap | Call | Behaviour |
|---|---|---|
ii | indentation("inner", "inner") | Indented lines only — no border lines |
ai | indentation("outer", "inner") | Include the line above, exclude the line below |
aI | indentation("outer", "outer") | Include both border lines |
iI | indentation("inner", "inner") | Alias for ii |
If the cursor is on a blank line, the plugin seeks forward to the next non-blank line automatically. If the cursor (or the resolved non-blank line) has zero indentation, the operation warns and aborts rather than selecting the entire file unexpectedly.
Config option
textobjs.indentation.blanksAreDelimiter (default: false)
When false, blank lines inside the indented block are treated as part of it and traversed through. When true, blank lines act as hard delimiters, stopping the selection at the first blank line encountered in either direction.
Visual example
print("Hello,"):
dii— deletes only the four indented linesdai— deletes the indented lines plusdef greet(name):daI— deletes everything shown above including the unindented line after
Custom keymap example
restOfIndentation
Function: restOfIndentation()Default keymap:
R
Selects from the cursor line downward through all lines that have the same or higher indentation level — essentially the “forward half” of ii. It is useful for deleting the tail of a loop body, the remaining branches of a conditional, or any trailing lines in a block.
If the cursor is on a blank line the plugin uses the next non-blank line’s indentation as the reference. If that line has zero indentation the operation warns and aborts.
greedyOuterIndentation
Function: greedyOuterIndentation(scope)Default keymaps:
ig (inner), ag (outer)
Like the outer indentation text object (aI) but additionally expanded to include surrounding blank lines in both directions, making it behave similarly to Vim’s built-in paragraph objects ap/ip. This is particularly handy for selecting a function together with its preceding docstring or annotation.
- Inner (
ig) — expands to blank lines on both sides, but excludes the blank line below - Outer (
ag) — expands to blank lines on both sides, includes the blank line below (mirrorsapsemantics)
Visual example
Advanced recipes
The indentation text object is also the building block for two popular custom commands:dsi— Delete Surrounding Indentation: dedents the inner block and removes the border lines above and below. Analogous tods)from vim-surround but for indentation levels.ysii— Yank Surrounding Indentation: copies the two border lines surrounding the indented block into the+register without moving the cursor.