Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

vi mode in readline

by morgon (Priest)
on Feb 11, 2019 at 22:22 UTC ( #1229767=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1229767]
Approved by stevieb
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2020-09-29 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (150 votes). Check out past polls.

    Notices?