You are not logged in.
Pages: 1
Topic closed
I want to remap some of the vi command mode keybindings in ~/.inputrc. I originally did this by hacking the readline code, but that's just dumb...
I've got the keybindings mapped ok using key: command, for example:
d: backward-char to map backward char to d instead of to h.
However, the problem is, this is remapping the keys in insert mode instead of command mode! I tried wrapping the remappings in $if statements, thus:
$if mode=vi
#keymaps
$endifBut that does the same thing. I also tried $if mode=vi-command, but that disabled the new keymappings all together. Is there another mode I need to try, or do I have to map the keybindings some other way?
Dusty
Offline
Why are you changing vim's keybinding's in .inputrc, you should change them in .vimrc. with map <key> <set of functions>.
I am not sure what you mean by h and d. Do you mean how to move backwards in edit mode? if that's the case, maybe try something like: map d h (i am not sure if it works, you can check vim.org for a better description than mine) you can fool around from within vim by doing ":map d h" and seeing what happens, if that's what you wanted just add the line to your .vimrc
Offline
I'm not changing vim's bindings, I want to change readline's (ie: bash) bindings when it is set to vi-compatible mode. In vim, I have the d h t n j k and l keys remapped; I want to remap the same keys in vi compatible readline as well.
I originally did this by patching the readline source; I'd like to try it with keybindings now... didn't know you could bind keys in readline. The problem I am having is that it is binding in insert mode instead of in command mode.
Edit: I found this post for doing it in bash:
http://www.mail-archive.com/vox-tech@li … 04877.html
If it worked, that might be good enough, since bash is my most oft used readline app. However, I'm having some problems. I was able to make these keybindings work:
bind -m vi-command '"d": backward-char'
bind -m vi-command '"n": forward-char'But these ones do not:
bind -m vi-command '"h": next-history'
bind -m vi-command '"t": prev-history'
bind -m vi-command '"k": vi-delete-to'
bind -m vi-command '"l": vi-search-again'
bind -m vi-command '"j": vi-char-search'I don't think it's possible to do what I want to do without hacking the readline source. Some of the command mode functions in the vi mode source do tests on the actual charcter entered (ie: the d character for vi-delete-to). This means I can't remap any keys without editing these functions (ie: to bind k to vi-delete-to). I've already written a patch that applies my keybindings to the file instead of the default, but it would be much nicer if this could be done dynamically. I don't feel like writing that patch though! Maybe Xentac will do it...
Dusty
Offline
somewhat necro-threading, but got here through a search for readline .inputrc bind vi-commands. so if some one else does as well i'll leave this breadcrumb in hopes it helps others
got
bind -m vi-command '"h": next-history'to work with
bind -m vi-command '"h": "n"'assuming i understand what he is after. this seems to indicate a macro can be bound to a vi-command key. which is fun.
in regards to his first question on .inputrc a similar solution exists, although, thankfully is less verbose
$if mode=vi
#vi mode settings
set keymap vi-command
#droid search char forward(next) und back(prev)
"zn": ";"
"zp": ","
# derived from
# https://deut-erium.github.io/2024/01/28/inputrc.html
# end vi mode settingss
$endifobviously i was after something different dealing with default android keyboard issues in termux and ; being a screen over. may be nice to figure out for []()and friends.
Last edited by sondaeren (Today 17:16:34)
Offline
somewhat necro-threading
~22yrs. Somewhat. Bravo!
Offline
Mod note: Please refrain from necro-bumping. Please re-read our rules in this regard [1]. Closing.
Inofficial first vice president of the Rust Evangelism Strike Force
Offline
Pages: 1
Topic closed