Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 May 2003 09:58:38 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Jerry McAllister <jerrymc@clunix.cl.msu.edu>
Cc:        questions@freebsd.org
Subject:   Re: Screen and VI
Message-ID:  <20030526065838.GC28797@gothmog.gr>
In-Reply-To: <200305252101.h4PL1GIr021382@clunix.cl.msu.edu>
References:  <Law9-F346KZmcK8r6be000112b1@hotmail.com> <200305252101.h4PL1GIr021382@clunix.cl.msu.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2003-05-25 17:01, Jerry McAllister <jerrymc@clunix.cl.msu.edu> wrote:
> >
> > Anyone know why, while in screen if i move the cursor (arrow key on
> > keyboard) right i get the letter C ? (inside vi)
>
> Probably the arrow key sends ESC-C as its code.  something eats the ESC
> and that leaves C.

The arrow keys work fine in 'command mode' in vi(1) if TERM is set
properly in the environment.  In insert mode they don't but that's not
very bad.  They do work in vi clones from the ports, like vim, though.

> All the extra keys such as arrows, page up, down, etc send ESC sequence
> codes -I don't know all the codes.  They're probably documented somewhere.
> Most are versions are probably based on the DEC VT100 and VT200 codes from
> back in ancient history.

The termcap sources are the definitive guide for finding out what each
terminal expects.  Alas, they're not very human-friendly to read.

> Generally we tell people not to use the arrow keys with in vi, but if
> your terminal configuration is set up right and your network is fast
> you can do it.    So, you have to figure out how to set up TERM.
>
> Maybe someone else will know the actuall setting information.

I usually fire up screen(1) in my console ttys or xterm windows, and
then set TERM=vt220.  This is monochrome, but all the arrow keys work
fine.  I even managed to make ALL the special keys like Insert, DEL,
Home, End, PageDown and PageUp to work 'as expected' in Emacs with the
following bindings in my .emacs file:

    ;; Key bindings.
    (global-set-key "\C-c,"  'goto-line)
    (global-set-key "\C-cw"  'delete-trailing-whitespace)
    (global-set-key "\C-xrs" 'bookmark-save)
    (global-set-key "\C-s" 'isearch-forward-regexp)
    (global-set-key "\C-r" 'isearch-backward-regexp)

    ;; Some bindings to make using Emacs nicer on vt220 terminals.
    (global-set-key "\C-h"          'backward-delete-char)
    (global-set-key [delete]        'delete-char)
    (global-set-key [deletechar]    'backward-delete-char)
    (global-set-key "\M-\C-h"       'backward-kill-word)
    (global-set-key [home]          'beginning-of-line)
    (global-set-key [find]          'beginning-of-line)
    (global-set-key [end]           'end-of-line)
    (global-set-key [select]        'end-of-line)

- Giorgos



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030526065838.GC28797>