readlinekey-bindingsvifm

VIFM: Remapping control right/left in command-line mode


I'm not a big fan of the command line readline keyboard shortcuts so I'm hoping to remap C-Right/C-Left to navigate one word back/forward and C-BS and C-Del to delete one word back/forward. However, after reading the documentation and forumns, I'm not able to figure out how to do this.

Currently, when C-left/C-right are typed in the command line, the cursor doesn't move and instead keycodes are inserted (C-left = [1;5D, C-right = [1;5C). I've tried many remappings but the mappings that I would think would work best for this are:

cmap <C-right> <A-f>
cmap <C-left> <A-b>

I was able to figure out how to delete one word back using the following mappings (on further review there is documentation in the VIFM manual regarding mapping BS):

cnoremap <BS> <C-w>
cnoremap <C-h> <C-w>

However, I'm still uncertain on how to map delete one word forward using C-Del. When I use the following remapping for C-Del, the result is that one character to the left of the cursor is deleted. Note, when I use other C-* combinations for delete word forward the remappings actually works making me think that it may not be possible to remap C-Del:

cmap <C-Del> <A-d>

I'm using VIFM version 0.12 on Arch Linux. Any suggestions?


Solution

  • List of keys that are supported by angle-bracket notation is available in the documentation. And combinations of Ctrl with arrow keys are not there.

    See this GitHub issue for a discussion of why and an example of how to work around it:

    " ctrl-right
    cnoremap <esc>[1;5C <a-f>
    " ctrl-left
    cnoremap <esc>[1;5D <a-b>
    " ctrl-del
    cnoremap <esc>[3;5~ <a-d>
    

    At this point I'm still not sure that these sequences are common enough among different terminal types to be hard-coded and not cause trouble.