12

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?

1
  • 4
    Take a look at the bind built-in command in bash, or if you want the changes to be uniform across all readline apps, modify ~/.inputrc. – jw013 Dec 26 '11 at 20:42
15

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.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.