Map key in object-selection submode

there’s a object mode in map, but we actually have multiple modes, like inner, outer. (this is misleading and is not explicated in the docs). installing a map in object mode will run the same procedure in all object modes.

how do I specify different procedures for different object modes without reimplementing all of them in a user mode? I can’t find any documentation about this. I’m guessing I have to involve %val{object_flags} for this but I find no examples for it.

Actually, there’s two expansions you’ll need to look at: %val{object_flags} and %val{select_mode}.

Probably what you’d do is write a command that takes those values as arguments:

define-command my-object-selection -hidden -params 2 %{
    # ...implementation...
}

…and then write a mapping that calls it:

map buffer object t '<a-semicolon>my-object-selection %val{object_flags} %val{select_mode}<ret>'

How you implement :my-object-selection to handle those modes really depends on what kind of object you’re trying to select.

Key object_flags select_mode
<a-a> to_begin|to_end replace
<a-i> to_begin|to_end|inner replace
[ to_begin replace
{ to_begin extend
] to_end replace
} to_end extend
<a-[> to_begin|inner replace
<a-{> to_begin|inner extend
<a-]> to_end|inner replace
<a-}> to_end|inner extend
2 Likes