Monday, August 31, 2009

Best config setting ever

echo 'set editing-mode vi' >>~/.inputrc
This will enable vi-editing mode for all commands that use the GNU readline library (e.g. bash, python, bc, etc.), not only the shell. For the shell only (including non-bash shells), add 'set -o vi' to your shrc file.

I don't know why I didn't do this before given that I'm a pretty hard vi user. Still, for some reason, I kept using emacs-like key bindings for command-line editing. Not any more! However, be careful: if you are used to vim's visual editing mode, you'll keep hitting 'v' in the command line and getting super annoyed.

Enjoy!

4 comments:

Bixen said...

Thank you, Julio. I'm going to use this profusely :-)

mirabilos said...

Hi! I need a maintainer for mksh’s – http://mirbsd.de/mksh – Vi command line editing mode, because I don’t use it. You might want to look out for bugs, I’ve fixed several dozen of them (e.g. horizontal scrolling bugs) in the Emacs command line editing mode. UTF-8 support (press € and hit backspace only once instead of three times, and the cursor position is intact too) is also missing from the Vi mode code.

It’s of course in pkgsrc®…

Lluis said...

[(control g)]

Curt Sampson said...

Being a NetBSD user, you ought not forget to set up your .editrc for the editline library, too. (Or does editline read .inputrc these days?)

My .editrc:

bind -v
psql:bind \\t rl_complete
ftp:bind \\t ftp-complete
bind \\t rl_complete

My .inputrc

set editing-mode vi
set match-hidden-files off
set completion-ignore-case on
Tab: complete