Best command key for use with GNU screen

231 views
Skip to first unread message

Michael Henry

unread,
Mar 7, 2009, 9:41:46 AM3/7/09
to vim...@googlegroups.com
All,

I've been putting off learning GNU screen for years now, despite the
rave reviews I've seen. I've come across yet another article[1] about
GNU screen, and it has gotten me interested in trying it again.

The thing that always stops me in my tracks, though, is choosing a
command key. By default, screen uses control-A as the command key. I
have long-standing muscle memory of using control-A at the Bash prompt
to move to the start of line, and I think it would drive me crazy to
keep invoking screen by mistake.

If any of you guys use GNU screen, have you remapped the command key?
If so, what key have you found convenient? I expect I'll have to give
up some Vim keystroke to use as the screen command key, but I thought
I'd see if anyone has a good recommendation.

Thanks,
Michael Henry

[1]: http://www.ibm.com/developerworks/aix/library/au-gnu_screen/

Tony Mechelynck

unread,
Mar 7, 2009, 10:03:29 AM3/7/09
to vim...@googlegroups.com

I'd say use whatever seems appropriate to you, and change it as soon as
you notice a problem. One person's "best choice" can be "far from best"
to the next guy.

I'm conscious that this isn't much of an answer -- but in many cases,
the best solution can be found by trial and error.


Best regards,
Tony.
--
"The sooner all the animals are dead, the sooner we'll find their
money."
-- Ed Bluestone, "The National Lampoon"

Teemu Likonen

unread,
Mar 7, 2009, 10:09:47 AM3/7/09
to vim...@googlegroups.com
On 2009-03-07 09:41 (-0500), Michael Henry wrote:

> The thing that always stops me in my tracks, though, is choosing a
> command key. By default, screen uses control-A as the command key. I
> have long-standing muscle memory of using control-A at the Bash prompt
> to move to the start of line, and I think it would drive me crazy to
> keep invoking screen by mistake.

With "Ctrl-a a" you can send a single Ctrl-a to the terminal.

> If any of you guys use GNU screen, have you remapped the command key?

My text terminal is always XTerm+Screen so I use Screen a lot. I haven't
remapped the command key because I think "Ctrl+a a" is OK for running
beginning-of-line. But I would probably use:

escape ^zz

in my ~/.screenrc. In Vim and many text terminal applications Ctrl-z is
suspend key. I think it's not a big loss if you now use Ctrl-z for
Screen command and "Ctrl-z z" for suspend.

Christian Ebert

unread,
Mar 7, 2009, 10:15:35 AM3/7/09
to vim...@googlegroups.com
* Michael Henry on Saturday, March 07, 2009 at 09:41:46 -0500

> The thing that always stops me in my tracks, though, is choosing a
> command key. By default, screen uses control-A as the command key. I
> have long-standing muscle memory of using control-A at the Bash prompt
> to move to the start of line, and I think it would drive me crazy to
> keep invoking screen by mistake.

Same here.

> If any of you guys use GNU screen, have you remapped the command key?
> If so, what key have you found convenient? I expect I'll have to give
> up some Vim keystroke to use as the screen command key, but I thought
> I'd see if anyone has a good recommendation.

I use ctrl-space. I've been told that the mapping is take in
emacs ;-) Note that you can always access these via the second
escape key.

It took me some time to find out how to set Ctrl-space in
screenrc, so in case you want to follow my bad example:

escape ^@a

c
--
Vim plugin to paste current GNU Screen buffer in (almost) any mode:
<http://www.vim.org/scripts/script.php?script_id=1512>

bill lam

unread,
Mar 7, 2009, 10:37:04 AM3/7/09
to vim...@googlegroups.com
On Sat, 07 Mar 2009, Michael Henry wrote:
> The thing that always stops me in my tracks, though, is choosing a
> command key. By default, screen uses control-A as the command key. I
> have long-standing muscle memory of using control-A at the Bash prompt
> to move to the start of line, and I think it would drive me crazy to
> keep invoking screen by mistake.

On the contrary vim works very well with screen. ctrl-a is used by vim
to increment a character by I don't need it, so that while using vim
it can freely switch to other screens. For the bash shell I use the
vi key binding. Type "esc 0" will move to the beginning just the same
as vim. In fact programs (including bash) that use readline should
use vi key binding by customizing the ~/.inputrc

# set editing mode to vi-like key binding
set editing-mode vi
set keymap vi
set convert-meta on

I used to puzzle why edit command key for bash is so hard to memorise,
it turned out that the default key binding for bash is emacs.

--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩113 杜甫 旅夜書懷
細草微風岸 危檣獨夜舟 星垂平野闊 月湧大江流
名豈文章著 官應老病休 飄飄何所似 天地一沙鷗

Anton Sharonov

unread,
Mar 7, 2009, 1:38:26 PM3/7/09
to vim...@googlegroups.com
bill lam wrote:
> For the bash shell I use the vi key binding. Type "esc 0" will
> move to the beginning just the same as vim.

Same here - default CTRL-A is therefore just fine in my opinion.

> In fact programs (including bash) that use readline should use
> vi key binding by customizing the ~/.inputrc
>
># set editing mode to vi-like key binding
>set editing-mode vi
>set keymap vi
>set convert-meta on

Hmm. I also use bash with VI-like keybindings, but I configure it
differently, in ~/.bashrc:

set -o vi

Just for my education - can you tell some examples of the
programs (besides bash) which using readline library and allows
you to use VI-like keybindings with the above settings in
~/.inputrc ?

--
Anton

bill lam

unread,
Mar 7, 2009, 8:07:43 PM3/7/09
to vim...@googlegroups.com
On Sat, 07 Mar 2009, Anton Sharonov wrote:
> Hmm. I also use bash with VI-like keybindings, but I configure it
> differently, in ~/.bashrc:
>
> set -o vi
>
> Just for my education - can you tell some examples of the
> programs (besides bash) which using readline library and allows
> you to use VI-like keybindings with the above settings in
> ~/.inputrc ?

Me too. `man readline` talks about key binding or both emacs and vi
mode and inputrc. And yet one program that I use seems to ignore
~/.inputrc . I bug the developer but null response. I guess it is up
the program to use that ~/.inputrc that why I added the word "should"
in my first message.

--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

唐詩215 李商隱 無題
相見時難別亦難 東風無力百花殘 春蠶到死絲方盡 蠟炬成灰淚始乾
曉鏡但愁雲鬢改 夜吟應覺月光寒 蓬萊此去無多路 青鳥殷勤為探看

Anton Sharonov

unread,
Mar 9, 2009, 5:47:15 PM3/9/09
to vim...@googlegroups.com
> Me too. `man readline` talks about key binding or both emacs
> and vi mode and inputrc. And yet one program that I use seems
> to ignore ~/.inputrc . I bug the developer but null response.
> I guess it is up the program to use that ~/.inputrc that why I
> added the word "should" in my first message.

Your message has inspired me to small investigation. Result: you
can use readline and VI-like keybindings with any kind of CLI
apps, even with those which are not linked with readline - for
example with oracle's sqlplus:

The trick described here [1] and uses 'rlwrap', readline wrapper
program.

~/.inputrc:

# settings pointed by bill lam on vim_use


set editing-mode vi
set keymap vi
set convert-meta on

~/.bashrc:

# ...
alias sqlplus='rlwrap sqlplus'
# ...

This works really. One strange thing though: ct<char>, cf<char>
commands aren't work as in bash, but remaining is ok so far. With
<C-R> you can start to incrementally search the last entered sql
statements. Very useful addition to dbext plugin, for all vim'ers
who uses oracle.

--
Anton

[1] how to edit command-line in sqlplus and rman (unix case)
http://www.oracledba.ru/notes_sqlplus_readline_en.html

pansz

unread,
Mar 9, 2009, 11:00:24 PM3/9/09
to vim...@googlegroups.com
bill lam 写道:

> # set editing mode to vi-like key binding
> set editing-mode vi
> set keymap vi
> set convert-meta on

will this have trouble when you need to input non-ascii characters?
I use the following setting:

set input-meta on
set output-meta on
set convert-meta off
set keymap vi
set editing-mode vi

bill lam

unread,
Mar 10, 2009, 12:06:01 AM3/10/09
to vim...@googlegroups.com
On Tue, 10 Mar 2009, pansz wrote:
> will this have trouble when you need to input non-ascii characters?
> I use the following setting:
>
> set convert-meta off

Yes, you are correct, but convert-meta is default on if I didn't miss
read the man.

graywh

unread,
Mar 10, 2009, 11:24:16 AM3/10/09
to vim_use
I have no need to edit right-to-left text in Vim so I use ctrl-7 (aka
ctrl-_) for screen.

Erik Falor

unread,
Mar 10, 2009, 12:50:53 PM3/10/09
to vim...@googlegroups.com
On Tue, Mar 10, 2009 at 08:24:16AM -0700, graywh wrote:
>
> I have no need to edit right-to-left text in Vim so I use ctrl-7 (aka
> ctrl-_) for screen.

Ctrl-_ is bound to undo in readline's default configuration.

I found that Ctrl-o is not bound by readline in the default
configuration, so that is what I use.

However, that keystroke is very handy in Vim, where in normal mode it
jumps the cursor to a prevoius position, or in insert mode puts you
temporarily into normal mode. I can still access this function
indside of Screen by typing Ctrl-o o, but it is really trying on my
muscle-memory to switch between using Vim both in and out of Screen.
So, you could say that I'm in the market for a new command key.

Alas, a perusal of `man readline` reveals that there are precious few
unused key combinations.

--
Erik Falor
Registered Linux User #445632 http://counter.li.org

kba

unread,
Mar 10, 2009, 1:27:29 PM3/10/09
to vim...@googlegroups.com

I use Ctrl-Q for switching. It clashes with terminal flow control (Ctrl-Q
and Ctrl-S), but I disable that anyway whereever I use screen. It has the
advantage of being just an alias for Ctrl-V in both readline and vim.

Besides, in some terminal apps (e.g. rtorrent), ctrl-Q is the quit
mapping and having to escape it through screen prevents me from
accidently quitting on a regular basis.

The only time I use Ctrl-Q in vim is when I want to close the last
window with ^W^Q. Again, I think the need to escape it is a feature.

Finally, it can be used painlessly used with one hand, even better than
Ctrl-A in my opinion.

- kba

Markus Banfi

unread,
Mar 11, 2009, 2:19:40 AM3/11/09
to vim...@googlegroups.com
Hi,

I like to use iPython for interactive work with Python code and modules.
It uses readline and being able to use vi keybindings adds even more
power to the tool for me.

-Markus-

2009/3/7 Anton Sharonov <anton.s...@gmail.com>:

> ...

Reply all
Reply to author
Forward
0 new messages