I recently found out about vi-mode under bash:<p><pre><code> set -o vi
</code></pre>
I love it - but there's a problem: over the years I've formed "muscle memory" for the default bash (actually, readline) shortcuts:<p><pre><code> "ESC-." will reproduce my last line's last argument
"Ctrl-a" will take me to the line's beginning
"Ctrl-e" will take me to the line's end
"Ctrl-w" deletes the word before the cursor
"Ctrl-l" clears the screen
</code></pre>
These obviously don't work in vi-mode - "ESC-." for example switches to VI command mode (because of ESC) and then "." repeats the last inserted word.<p>After a bit of research, I found a way to have my cake and eat it too - this is what you need in your .bashrc:<p><pre><code> set -o vi
bind -m vi-command ".":insert-last-argument
bind -m vi-insert "\C-l.":clear-screen
bind -m vi-insert "\C-a.":beginning-of-line
bind -m vi-insert "\C-e.":end-of-line
bind -m vi-insert "\C-w.":backward-kill-word
</code></pre>
This way, the shortcuts I've been using for decades still work - and I can still switch to vi command mode (with ESC) and enjoy the immense powers of vi.<p>Granted, I am losing a bit of functionality (e.g. the repeating of a series of commands with a single '.') ; but if you are like me, you'll prefer this tradeoff.<p>P.S. If you need further commands to replicate, just look them up in "man bash" (search for "Readline Command Names").