I’m really grateful for your help here.
Reading your code example made me think that surely this must already exist for ST. The ToggleWords plugin allows toggling between words inside user-defined arrays, like this:
true -> false
yes -> no
on -> off
0 -> 1
left -> right
top -> bottom
up -> down
width -> height
This looks awesome. Their out-of-the-box shortcut is Ctrl+Alt+x, which is fine, but using a vim leader would make more sense inside the vim world.
The leader I use is <space>
.
I tried modifying their keymapping as follows:
{
"keys": [" ", "t"],
"command": "toggle_word",
}
This works, but it works in all modes, including insert mode, which isn’t acceptable.
I therefore tried mapping it inside .neovintageousrc, as you suggested, but I can’t find a way to make it work. This is what I’ve tried that doesn’t work:
nnoremap <leader>t :toggle_word<CR>
When I tell the console to log all commands, it just reports
command: _nv_feed_key {"key": "<space>"}
command: _nv_feed_key {"key": "t"}
but it doesn’t actually run the toggle_word command. (Using Ctrl+Alt+X does run the command.)