Understanding the "<a-;> run command in object context"

Hi, when selecting an inner or whole object with <a-i> or <a-a> one can press <a-;> to “run command in object context”.

I have checked the :doc and I understand that I can run a command with access to special %val , but I don’t understand the purpose of those and how I could use them

Could it be possible to have a simple example of using this command with some special object value ?

Lets say you want to add a new object to the object selection commands (<a-i>, <a-a>, <a-[>, <a-]>, [ and ]) but it’s not something that is easily described by regex (e.g. you want to select functions bodies while supporting multiple languages, this requires a semantic parser like tree sitter with a grammar for each supported language). You will need to provide some options to the tree sitter command to get all the different possible permutations:
%val{select_mode} is “extend” or “replace”
%val{object_flags} is some combination of “inner”, “to_begin” and “to_end”.

New commands are added to every object mode with
map global object f "<a-:> tree-sitter-select-function<ret>"
I.E. they are all the treated as the same mode, you can’t have
map global inner-object f "<a-:> tree-sitter-select-function inner|start|end<ret>"
map global outer-object-start f "<a-:> tree-sitter-select-function outer|start|extend<ret>"

1 Like

Thanks you it’s clear now. I feel the documentation not very good on this . The design seems a bit twisted but I guess it does the job.