I'm configuring my sway keybindings and want to bind workspaces a to z.
for example
bindsym $mod+Shift+a workspace a
bindsym $mod+Shift+b workspace b
...
bindsym $mod+Shift+z workspace z
How can I quickly complete these contents on nvim?
This can be done using put
, map
, nr2char
, printf
map({expr1}, {expr2})
{fmt}
, where %
items are replaced by
the formatted form of their respective arguments.:put =map(range(97,122), 'nr2char(v:val)')
output:
a
b
...
z
:put =map(range(97,122), '\"aa \" . nr2char(v:val) . \" bb\"')
output:
aa a bb
aa b bb
...
aa z bb
:pu =map(range(97,122), 'printf(\"bindsym $mod+Shift+%s workspace %s\", nr2char(v:val), nr2char(v:val))')
-- or
:pu =map(range(97,122), {_, ch -> printf('bindsym $mod+Shift+%s workspace+%s', nr2char(ch), nr2char(ch)) })
output:
bindsym $mod+Shift+a workspace a
bindsym $mod+Shift+b workspace b
...
bindsym $mod+Shift+z workspace z