kontur.nvim provides powerful and intuitive text objects to select and operate on blocks of text based on their structure. It understands code indentation, Markdown-style headings, repeatable prefix patterns, and Markdown tables, allowing you to work with logical blocks seamlessly.
The basic concept is to select neighboring lines of text base on the indent level under the cursor.
When searching the lines, the operation means all the neighboring lines whose indent level is equal or lower than the line under the cursor.
Including any empty line when searching.
UPDATE:
Now we can select content by Markdown heading level.
Using vih to select all lines under the nearest Markdown heading, and vah to include the heading line itself.
UPDATE 2:
Now we can select lines which share the same repeatable prefix pattern, meaning the same leftmost non-whitespace marker. r stands for repeatable prefix pattern. For example, all lines with a comment prefix // can be selected by vir. It also supports numbered lists such as 1. , 2. , ..., 10. , 11. .
UPDATE 3:
Now we can select a Markdown pipe table with vit. The selector works from the header row, delimiter row, or any body row.
The default keystroke for indent line is i. If you want to use another character, you can set the config object:
require("kontur").setup({
indent_object_char = 'i', -- now use `ii` to select by indent
heading_object_char = 'h', -- now use `ih` to select by markdown heading
prefix_object_char = 'r', -- now use `ir` to select by repeatable prefix pattern
table_object_char = 't', -- now use `it` to select by markdown table
})Here is a function:
local function test()
print(1)
print(2) <-- cursor here
print(3)
enduse vii to select function body (They all have the same indent level):
local function test()
β print(1)
β print(2)
β print(3)
endHere are some markdown texts:
# Header 1
- List 1
- Sub list 1
- Sub list 2 <-- cursor here
- Sub list 3
# Header 2use vii to select sub lists (without the empty line):
# Header 1
- List 1
β - Sub list 1
β - Sub list 2
β - Sub list 3
# Header 2Here are some markdown texts:
# Header 1
- List 1
- Sub list 1
- Sub list 2 <-- cursor here
- Sub list 3
# Header 2use vih to select all lines under the nearest Markdown heading:
# Header 1
β- List 1
β - Sub list 1
β - Sub list 2
β - Sub list 3
# Header 2use vah to select the heading and all its content, trimming trailing blank lines:
β# Header 1
β- List 1
β - Sub list 1
β - Sub list 2
β - Sub list 3
# Header 2Here is some code with comments that share the same repeatable prefix pattern, // :
let a = 42;
// This is a comment
// This is another comment <-- cursor here
// And one more
print(a);
use vir to select the comment block:
let a = 42;
β// This is a comment
β// This is another comment <-- cursor here
β// And one more
print(a);
Or you can select the numbered list:
1. First item
2. Second item
3. Third item <-- cursor here
...
11. Eleventh item
use vir to select the numbered list:
β1. First item
β2. Second item
β3. Third item
β...
β11. Eleventh item
Here is a Markdown pipe table:
Before
| Name | Align | Count |
| --- | :---: | ---: |
| Ada | mid | 1 | <-- cursor here
| Linus | low | 2 |
Afteruse vit to select the whole table:
Before
β| Name | Align | Count |
β| --- | :---: | ---: |
β| Ada | mid | 1 |
β| Linus | low | 2 |
After