I’m looking for a less hacky way to do this:
# Marks
declare-user-mode set-mark
map global normal M ': enter-user-mode set-mark<ret>'
map global set-mark a ': set-mark a<ret>'
define-command set-mark -docstring "set-mark [<register>]: save selection to <register>" -params 1 %{
execute-keys %sh{ echo '"'"$1"Z }
}
declare-user-mode restore-mark
map global normal m ': enter-user-mode restore-mark<ret>'
map global restore-mark a ': restore-mark a<ret>'
define-command restore-mark -docstring "restore-mark [<register>]: restore selection from <register>" -params 1 %{
execute-keys %sh{ echo '"'"$1"z }
}
The basic idea is I can type Ma
to create a selection and ma
to restore it. However, the only way I know how to pass the register into the set-mark
and restore-mark
commands is by creating a user-mode mapping for every single register. Is there a less hacky way to do it?
Bonus question: is there a less hacky way to run execute keys "%opt{1}Z
? I can’t get the escaping right unless I use %sh{}