Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

vi keys navigation mode

2 views
Skip to first unread message

Chris Jones

unread,
Jan 2, 2010, 3:14:04 AM1/2/10
to
I'm addicted to vi/vim's basic cursor movement model, which pretty much
adds up to 'hjkl' moving one terminal cell left/down/up/right and
optionally Ctrl-U and Ctrl-D paging half a screen up/down and possibly
some variation on the 'g' key to emulate <Home> and <End>.

Unfortunately many applications and utilities that run full-screen
inside an xterm do not support this model, even as an option.

Say for instance that I would like debian's dpkg-reconfigure collection
of utilities to support 'vi-keys'.

How would I go about doing that?

Not sure that makes any sense, but could it be possible to remap the
keyboard dynamically, possibly by front-ending such applications in
order to avoid modifiying their code?

Thanks,

CJ

Russell Shaw

unread,
Jan 2, 2010, 4:23:30 AM1/2/10
to

Many GNU console apps use the Readline library to do the command prompt.
It has a Vi mode:

http://tiswww.case.edu/php/chet/readline/rluserman.html#SEC22

You might find an environment variable or readline config setting
to permanently use Vi mode.

The Bash shell has a Vi mode setting because it uses Readline too.

Chris Jones

unread,
Jan 2, 2010, 3:39:49 PM1/2/10
to

Hmm.. I should have been a bit more explicit that I was talking about
full screen applications, usually ncurses-based, not line-mode stuff
(where I'm happy to use emacs-keys anyway).

I don't see how readline options could help with this.

But the parallel is interesting, since what I'm looking for is bringing
the readline vi mode magic to ncurses applications.

To put it bluntly, the dream scenario would be to have all full screen
text-mode applications switch to vi-keys navigation simply by setting an
environment variable called maybe $NMODE to vi and be done with it.

:-)

Thank you for your comments.

CJ

Lucas Levrel

unread,
Jan 5, 2010, 5:54:43 AM1/5/10
to
Le 2 janvier 2010, Chris Jones a écrit :

> I'm addicted to vi/vim's basic cursor movement model, which pretty much
> adds up to 'hjkl' moving one terminal cell left/down/up/right and
> optionally Ctrl-U and Ctrl-D paging half a screen up/down and possibly
> some variation on the 'g' key to emulate <Home> and <End>.
>
> Unfortunately many applications and utilities that run full-screen
> inside an xterm do not support this model, even as an option.
>
> Say for instance that I would like debian's dpkg-reconfigure collection
> of utilities to support 'vi-keys'.
>
> How would I go about doing that?

Some WMs have an applet to switch keyboard layouts. If yours have one, you
could set up a custom layout and switch between normal and custom at will
(possibly through a keyboard shortcut).

--
LL

Florian Rehnisch

unread,
Jan 6, 2010, 12:43:54 AM1/6/10
to
o Chris Jones <cjns...@optimum.net>:

> I'm addicted to vi/vim's basic cursor movement model, which pretty much
> adds up to 'hjkl' moving one terminal cell left/down/up/right and
> optionally Ctrl-U and Ctrl-D paging half a screen up/down and possibly
> some variation on the 'g' key to emulate <Home> and <End>.

I use the larswm window manager, and I defined the command for
moving and resizing windows vi-stylish (larswm is mostly keyboard
driven minimal wm).

see http://www.florianrehnisch.de/tmp/dotlarswmrc
--
flori
Vim-Hilfe auf Deutsch http://www.florianrehnisch.de/vimhelp/

Chris Jones

unread,
Jan 12, 2010, 6:38:52 AM1/12/10
to
On Wed, 6 Jan 2010 05:43:54 +0000 (UTC), Florian Rehnisch <eix...@gmx.de> wrote:
> o Chris Jones <cjns...@optimum.net>:

>> I'm addicted to vi/vim's basic cursor movement model, which pretty
>> much adds up to 'hjkl' moving one terminal cell left/down/up/right
>> and optionally Ctrl-U and Ctrl-D paging half a screen up/down and
>> possibly some variation on the 'g' key to emulate <Home> and <End>.

> I use the larswm window manager, and I defined the command for
> moving and resizing windows vi-stylish (larswm is mostly keyboard
> driven minimal wm).
>
> see http://www.florianrehnisch.de/tmp/dotlarswmrc

I'll take a peek, but apart from possibly stealing some predefined
keyboard actions, I'm not sure the a window manager can do any remapping
and pass them on to the applications - i.e. I hit 'j' and the window
manager converts it to a 'Down' before passing it to a program executing
under an xterm. But since I don't see myself modifying dozens or maybe
hundreds of ncurses programs and utilities to 'teach them the correct
keyboard behavior, :-)'.. and maintaining all those changes thereafter,
that's definitely what I had in mind: something that would front-end
their 'keyboard listening' and convert, e.g. 'hjkl' into 'arrow keys'
strokes.

Come to think of it, this does not look too promising: I don't want
arrow keys substituted when the application asks me something like 'What
happened?' and I'm entering 'he just killed lucy' in a data entry field,
for instance. Unless possibly implement some time-related mechanism,
where the front end waits a bit and if no other key stroke follows
within a certain time frame, it makes a decision to convert the user's
hjkl's to cursor movement actions.

Ah.. probably would cause more aggravation than anything.

Thanks to both for your comments.

CJ

Chris Jones

unread,
Feb 5, 2010, 8:51:52 AM2/5/10
to
On Tue, 5 Jan 2010 11:54:43 +0100, Lucas Levrel <lucas....@univ-paris12.fr> wrote:
> Le 2 janvier 2010, Chris Jones a écrit :

Un mis-à-jour pour toutes celles qui retenaient leur souffle:

[..]

>> For instance, I would like debian's dpkg-reconfigure collection of


>> utilities to support 'vi-keys'.
>>
>> How would I go about doing that?

> Some WMs have an applet to switch keyboard layouts. If yours have one,
> you could set up a custom layout and switch between normal and custom
> at will (possibly through a keyboard shortcut).

As advised, I have decided to settle for a decent enough workaround,
whereby I use xmodmap to set up a "navigation pad" that I access by
depressing the left Windows key. The cursor keys are mapped to "hjkl"
and "uiop" to PageUp/Down and Home/End.

Not totally transparent but fits in tolerably well with my keyboarding
habits and does the job both with ncurses and GTK applications.

The only problem I have run into so far is that my version of Xorg,
probably the video card driver, sometimes messes up the mappings when I
switch back and forth between X sessions running on different VTs.

Rather disorienting at first, when you're not yet quite used to the new
combos, but it seems that X only needs a nice hug in the form of a
quick commute to a text-mode console to recover.

CJ

Lucas Levrel

unread,
Feb 9, 2010, 5:13:09 AM2/9/10
to
Le 5 février 2010, Chris Jones a écrit :

> Un mis-à-jour pour toutes celles qui retenaient leur souffle:

:-) Thanks for the report!

--
LL

0 new messages