martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.26k stars 258 forks source link

can a key binding action be executed on a selection without mapping it to something? #979

Closed honestSalami closed 3 years ago

honestSalami commented 3 years ago

I want to run "vis-selections-align-indent-left", but I can't use the default mapping, and I don't want to make a new mapping for it right now. Is there a way to run it on the current selection without mapping it first?

ninewise commented 3 years ago

There's no such functionality by default, AFAIK. However, you could define a function such as:

vis:command_register("feed", function(argv, force, cur_win, selection, range)
    vis:feedkeys(argv[1])
end, 'feed keys to vis')

Then you can call :feed <vis-selections-align-indent-left>.

honestSalami commented 3 years ago

Thanks!