l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
January 6: Social gathering
Next Installfest:
TBD
Latest News:
Nov. 18: Club officer elections
Page last updated:
2003 Mar 31 10:24

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] vi key bindings, readline and bash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] vi key bindings, readline and bash



solved by donald j. bindner who was kind enough to respond to a post i
made to comp.unix.questions ... god knows how long ago.   a year?  two
years maybe?

as i suspected, the problem is that debian testing and unstable have
newer versions of readline than suse, redhat or debian stable (the three
platforms his key bindings worked under).

donald figured out that the new readline now uses a timing feature to
help it distinguish between an escape character and an escape character
than occurs as part of a keycode (like the F1 key).   he wrote the
following bindings.

basically, you're in emacs mode unless you press escape.  then you're in
vi mode.  this is nice because you have powerful and short vi commands
yet still have the emacs conveniences like "up arrow" instead of typing
"escape up arrow".

here's don's readline bindings:



## .bash_bindings: source this file from your .bashrc or .bash_profile
#
# For those who want to use Vi bindings in bash, this corrects a
# few annoyances:
#
# 1) up and down arrows retrieve history lines even in insert mode
# 2) left and right arrows work in insert mode
# 3) Ctrl-A and Ctrl-E work how you expect if you have had to
#    live in Emacs mode in the past.
# 4) So does Ctrl-D.

## Command-mode bindings
# Ctrl-A or Home: insert at line beginning like in emacs mode
 bind -m vi-command 'Control-a: vi-insert-beg'
# Ctrl-E or End: append at line end like in emacs mode
 bind -m vi-command 'Control-e: vi-append-eol'
# to switch to emacs editing mode
 bind -m vi-command '"ZZ": emacs-editing-mode'

## Insert-mode bindings
# up arrow or PgUp: append to previous history line
 bind -m vi-insert '"\M-[A": ""'
 bind -m vi-insert '"\M-[5~": ""'
 bind -m vi-insert 'Control-p: previous-history'
# dn arrow or PgDn: append to next history line
 bind -m vi-insert '"\M-[B": ""'
 bind -m vi-insert '"\M-[6~": ""'
 bind -m vi-insert 'Control-n: next-history'
# Ctrl-A: insert at line start like in emacs mode
 bind -m vi-insert 'Control-a: beginning-of-line'
# Ctrl-E: append at line end like in emacs mode
 bind -m vi-insert 'Control-e: end-of-line'
# Ctrl-D: delete character
 bind -m vi-insert 'Control-d: delete-char'
# Ctrl-L: clear screen
 bind -m vi-insert 'Control-l: clear-screen'

## Emacs bindings
# Meta-V: go back to vi editing
 bind -m emacs '"\ev": vi-editing-mode'

## Specify vi editing mode
 set -o vi




begin Charles Polisher <cpolish@attbi.com> 
> Peter Jay Salzman wrote:
> > begin Charles Polisher <cpolish@attbi.com> 
> > > Peter Jay Salzman wrote:
> > > > chuck,
> > > > 
> > > > is your libreadline 4.2 or 4.3?    every 4.2 system i've tried, it
> > > > works.
> > > > 
> > > > it doesn't seem to work on 4.3.
> > > 
> > > I locate'd this file: /lib/libreadline.so.4.2
> > > so I guess it's 4.2...
> > > 
> > > Could it be something to do with $TERM ? Mine's
> > > set to "xterm", but iirc sometimes people use
> > > "linux" or some such. ?
> > 
> > i used to set mine to linux, but switched over to xterm awhile ago.
> > 
> > hrmmm... i think perhpas it's time to post a question to bug-readline.
> > 
> > thanks, chuck.  i appreciate you putting up with my questions.  :)
> 
> I'm always pleased if I can help,
> 
> 
> Chuck
> -- 
> Object-oriented programming is an exceptionally bad idea which
> could only have originated in California.    --Edsger Dijkstra

-- 
Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.