xml tag object:
map -docstring "xml tag objet" global object t %{c<lt>([\w.]+)\b[^>]*?(?<lt>!/)>,<lt>/([\w.]+)\b[^>]*?(?<lt>!/)><ret>}
select inside brackets <stuff>select me</stuff>
map global object h 'c<gt>,<lt><ret>' -docstring "select in the (html) angle brackets"
select inside brackets select\me\ALL_OF_ME
map global object o 'c\s,\s<ret>' -docstring "select inbetween the whitespace"`
Select indented paragraph
Here’s a common scenario:
function foo() {
line a
line b
line c
line d
line e
}
Your cursor is on line b
and you want to quickly act on the first part of the function (line a
to line c
)
If you do a <a-i>i
to select indent you select the whole function body.
If you do a <a-i>p
to select paragraph you select the line with function foo() {
as well.
None of these text-objects is really satisfying alone here. It turns out that the intersection of both is what is needed:
define-command -hidden text-object-indented-paragraph %{
execute-keys -draft -save-regs '' '<a-i>pZ'
execute-keys '<a-i>i<a-z>i'
}
Credits goes to @occivink for this text-object.
Wow – that is something I have wanted a million times. Implementing instantly.
I now notice that the whole thing should be wrapped in an eval -save-regs ^ %{}
to avoid overwriting the mark register
And what do you bind it to generally @occivink? And any more gems?