http://qs321.pair.com?node_id=1229767

morgon has asked for the wisdom of the Perl Monks concerning the following question:

Hi, this works but seems to use the emacs editing mode when Term::Readline::Gnu is installed:
use strict; use Term::ReadLine; my $term = Term::ReadLine->new('a'); print "you entered: " . $term->readline("Enter something: ");
Is there a way to use vi-mode?

Many thanks!

Replies are listed 'Best First'.
Re: vi mode in readline
by morgon (Priest) on Feb 12, 2019 at 02:17 UTC
    To answer my own question (I am sure in a few year's time I'll have to look it up again and hop to find this then), this seems to work:
    use strict; use Term::ReadLine; my $term = Term::ReadLine->new('a'); # use vi-mode $term->parse_and_bind("set editing-mode vi"); print "you entered: " . $term->readline("Enter something: ");
Re: vi mode in readline
by dasgar (Priest) on Feb 12, 2019 at 00:57 UTC

    Doing a search on MetaCPAN turns up Term::Readline::Zoid::ViCommand. It's "Description" section states:

    This mode provides a "vi command mode" as specified by the posix spec for the sh(1) utility. It intends to include at least all key-bindings mentioned by the posix spec for the vi mode in sh(1). It also contains some extensions borrowed from vim(1) and some private extensions.

    I'm more familiar with Windows than Linux, so I'm not sure if that matches what you're looking for.