Remap bash vi keys?

I use Dvorak and vi, so when I found out about the vi mode in Bash, I was very excited. However, it would be even better if I could remap the movement keys to be the ones that I use in vi (I swap keys around until the movement keys are back on the home row in Dvorak).

How can I do this?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You can create a file named ‘.inputrc’ in your home directory.

# want vi to be the default editor for readline                      
set editing-mode vi                                            

# vi settings                                         
$if mode=vi                
    # normal mode                           
    set keymap vi-command                                 
    "j": beginning-of-history
    "l": backward-char
    "h": forward-char         
    "G": end-of-history
    # insert mode             
    set keymap vi-insert                          
    "jj": vi-movement-mode # remap escape   
$endif

These are my mappings, with the exception of l and h. I switched those here, to show you how you can switch keys.
I don’t know the Dvorak keys you want, just modify all those keys like you want.

man bash describes all the possiblities.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments