How do I add a keymap into fish vi keybindings?

Solution 1:

A couple of possibilities:

  • First, if you are currently using "*y to yank to the system clipboard, then you can see via bind in Fish that the default binding is:

    bind -M visual -m default '"*y' 'commandline -s | xsel -p; commandline -f end-selection repaint-mode'
    

    So you should be able to recreate that for SPACEc by:

    bind -M visual -m default \x20c 'commandline -s | xsel -p; commandline -f end-selection repaint-mode'
    
  • There's also the fish_clipboard_copy function listed in the docs for bind, so another possibility might be:

    bind -M visual -m default \20c fish_clipboard_copy
    

    ... but I assume you'll need to use the converse fish_clipboard_paste as well, rather than xsel.

Solution 2:

The error is because the binding is setting a command that is not valid. You cannot run "*y at the command line (and if you try with fish -c '"*y', you'll get the same error).

The command to bind needs to be just that - a command. That's why using fish_clipboard_copy works fine. There's no way to execute another keybinding, at least in fish 3.3.1 and before.