<?xml version="1.0"?>
<!DOCTYPE content [ <!ENTITY nbsp " "> ]>
<rdf:RDF xml:base="http://snarfed.org/rdf"
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:dc="http://purl.org/dc/elements/1.1/">

<rdf:Description rdf:about="http://snarfed.org">
  <dc:title> snarfed.org  </dc:title>
  <dc:description> draw group stream of consciousness </dc:description>
  <dc:creator> Ryan Barrett &lt;snarfed at ryanb dot org&gt; </dc:creator>
  <dc:language> en </dc:language>
  <dc:format> text/html </dc:format>
  <dc:rights> Copyright 2002-2007 Ryan Barrett </dc:rights>
</rdf:Description>

<rdf:Description rdf:about="http://snarfed.org/space/Emacs%20keybindings%20in%20GNU%20screen%27s%20copy-scrollback%20mode">
  <dc:title> Emacs keybindings in GNU screen's copy-scrollback mode </dc:title>
  <dc:creator> Ryan Barrett &lt;snarfed at ryanb dot org&gt; </dc:creator>
  <dc:date> 2003-01-01T05:00:00Z </dc:date>
  <dc:language> en </dc:language>
  <dc:format> text/html </dc:format>
  <dc:rights> Copyright 2002-2007 Ryan Barrett </dc:rights>

  <content>
    <p><a href="http://www.gnu.org/software/screen/"><img src="/space/terminal.jpg" alt="terminal.jpg" title="" /></a><a href="http://gnu.org/software/emacs/"><img src="/space/gnu.jpg" alt="gnu.jpg" title="" /></a><a href="/space/synchronizing GNU screen's paste buffer and the X selection"><img src="/space/X_logo.png" alt="X_logo.png" title="" /></a></p>

<p>When I'm working, I pretty much
live inside <a href="http://gnu.org/software/emacs/">Emacs</a>. It's my IDE, debugger, text
editor, email composer, spreadsheet, file manager, and all-around scratch pad.</p>

<p>I've burned Emacs' key bindings into my brain, so I go to great lengths to set
them in every program I use. That way, I don't have to context switch my
fingers' muscle memory when I task switch from coding to email, to IM, to the
web. Task switches may be a fact of life, but other unnecessary mental context
switches are evil incarnate.</p>

<p>I recently started using <a href="http://www.gnu.org/software/screen/">GNU screen</a>'s
<a href="http://www.delorie.com/gnu/docs/screen/screen_73.html">copy/scrollback mode</a> so
that I could copy from terminals with the keyboard. I use these commands in <a href="http://ryan.barrett.name/dotfiles/screenrc">my
.screenrc</a> to set up Emacs key
bindings in screen's copy/scrollback mode:</p>

<div class='p-shadow'><pre><code># emacs keybindings for navigation in copy mode
markkeys ^B=Y:^F=V:h=^B:l=^F:0=^A:$=^E

# C-space sets mark. markkeys does it in screen 4.0 and higher, but 3.9x
# needs the bindkey command. (note the ^@ escape sequence for C-space.)
markkeys ' '=^@
# bindkey -m ^@ stuff ' '

# page up and page down
bindkey -m -k kP stuff Y
bindkey -m -k kN stuff V

# failed attempt to make C-space work in i-search too
# bindkey -m ^@ eval "stuff \033" "stuff ^@" 

# special hack for C-e, since it should go *past*
# the last char. -m means this is for copy mode only.
bindkey -m ^e stuff "$^f"

# C-g and other keys just quit copy mode. Esc does nothing.
markkeys \033=\015=^G=^D=h=j=k=l=H=M=L=G=g=y=c=v=a=x=b=e=B=E=w
markkeys @=\033

# control arrows move by words. (set B, e, and w to F keys so that i can
# use them to move by words, but they themselves still quit copy mode.)
markkeys B=[:E=]:b={:e=}:w=&gt;
bindkey -m ^[Od stuff {  #"[[}"
bindkey -m ^[Oc stuff ]  #"}]^f"
</code></pre></div>

<p><br class='clearing' />See also:</p>

<ul>
<li><a href="/space/synchronizing GNU screen's paste buffer and the X selection">synchronizing GNU screen's paste buffer and the X selection</a></li>
<li><a href="/space/why I don't run shells inside Emacs">why I don't run shells inside Emacs</a></li>
<li><a href="/space/control arrow keys in rxvt, tcsh, and emacs">control arrow keys in rxvt, tcsh, and emacs</a></li>
<li><a href="/space/emacs keybindings in firefox">emacs keybindings in firefox</a></li>
<li><a href="/space/emacs keybindings with number keys">emacs keybindings with number keys</a></li>
<li><a href="/space/emacs page up page down">emacs page up page down</a></li>
</ul>

  </content>

  <rdf:Seq>

<rdf:li>
<rdf:Description rdf:about="#1160936273.49">
  <dc:source> http://snarfed.org/ </dc:source>
  <dc:title> Emacs keybindings in GNU screen's copy-scrollback mode </dc:title>
  <dc:creator> Marc </dc:creator>
  <dc:date> cmt_pubDate </dc:date>
  <dc:format> text/html </dc:format>

  <content>
    The thing that drives me nuts about screen still (even though I love it and use it daily) is when I search throught the scrollback with C-r, once I found the spot I want, I can't get out of incremental search unless I hit C-g, and then pops me back down to the bottom of the buffer! Do&nbsp; you know how to prevent that?
  </content>
</rdf:Description>
</rdf:li>

<rdf:li>
<rdf:Description rdf:about="#1160936895.51">
  <dc:source> http://snarfed.org/ </dc:source>
  <dc:title> Emacs keybindings in GNU screen's copy-scrollback mode </dc:title>
  <dc:creator> Marc </dc:creator>
  <dc:date> cmt_pubDate </dc:date>
  <dc:format> text/html </dc:format>

  <content>
    Hmmm, it seems ESC might do what I want. Don't know why I hadn't noticed that before.
  </content>
</rdf:Description>
</rdf:li>

<rdf:li>
<rdf:Description rdf:about="#1176409976.34">
  <dc:source> http://snarfed.org/ </dc:source>
  <dc:title> Emacs keybindings in GNU screen's copy-scrollback mode </dc:title>
  <dc:creator> proth </dc:creator>
  <dc:date> cmt_pubDate </dc:date>
  <dc:format> text/html </dc:format>

  <content>
    Were you able to move screen's C-a to some other keybinding?&nbsp; I use C-a to move to the beginning of a line, but screen wants to use that for its commands.&nbsp; How can I tell screen to pay attention to C-s, or anything else?
  </content>
</rdf:Description>
</rdf:li>

<rdf:li>
<rdf:Description rdf:about="#1176424329.69">
  <dc:source> http://snarfed.org/ </dc:source>
  <dc:title> Emacs keybindings in GNU screen's copy-scrollback mode </dc:title>
  <dc:creator> Ryan </dc:creator>
  <dc:date> cmt_pubDate </dc:date>
  <dc:format> text/html </dc:format>

  <content>
    sure! use the <code>escape</code> command. see <a href="http://www.linuxworld.com/news/2006/100306-gnu-screen.html?page=5">this tutorial</a>, or the <a href="www.linuxmanpages.com/man1/screen.1.php">man page</a>. i set it to tilde in <a href="http://ryan.barrett.name/dotfiles/screenrc">my&nbsp; .screenrc file</a>.
  </content>
</rdf:Description>
</rdf:li>

<rdf:li>
<rdf:Description rdf:about="#1176480902.44">
  <dc:source> http://snarfed.org/ </dc:source>
  <dc:title> Emacs keybindings in GNU screen's copy-scrollback mode </dc:title>
  <dc:creator> Barfoos </dc:creator>
  <dc:date> cmt_pubDate </dc:date>
  <dc:format> text/html </dc:format>

  <content>
    These two lines of your sample give me a syntax-error:<br />
<br />
markkeys 033=015=^G=^D=h=j=k=l=H=M=L=G=g=y=c=v=a=x=b=e=B=E=w<br />
markkeys @=033<br />
<br />
I use the following screenrc, it covers emacs-like window-management:<br />
<br />
escape ^x^x<br />
bind o focus<br />
bind 0 remove<br />
bind 1 only<br />
bind 2 split<br />
bind = resize =<br />
bind ^b windowlist -m<br />
<br />
One thing I miss is that C-X b RET should switch between two sessions. Any ideas?
  </content>
</rdf:Description>
</rdf:li>

<rdf:li>
<rdf:Description rdf:about="#1176484388.04">
  <dc:source> http://snarfed.org/ </dc:source>
  <dc:title> Emacs keybindings in GNU screen's copy-scrollback mode </dc:title>
  <dc:creator> Ryan </dc:creator>
  <dc:date> cmt_pubDate </dc:date>
  <dc:format> text/html </dc:format>

  <content>
    ack, the templating system ate the escape characters. fixed. thanks for the nudge.<br />
<br />
as for C-x b RET, off the top of my head, no, but i do know that bindkey can do amazing things.
  </content>
</rdf:Description>
</rdf:li>

<rdf:li>
<rdf:Description rdf:about="#1178526366.11">
  <dc:source> http://snarfed.org/ </dc:source>
  <dc:title> Emacs keybindings in GNU screen's copy-scrollback mode </dc:title>
  <dc:creator> Dan </dc:creator>
  <dc:date> cmt_pubDate </dc:date>
  <dc:format> text/html </dc:format>

  <content>
    Sorry... I posted this comment on the wrong article!<br />
<br />
That is nice, but I don't think you go far enough... What about mapping C-a to C-x (making commands much more Emacs finger friendly) ... For example, I am now totally stuck on C-a p for 'switching buffers' after C-a c in screen. For this to be 'Emacs' it should be C-x b...<br />
<br />
Removing the C-a would be a start...<br />
<br />
Thanks for the others though... but where is C-f / C-b ? did you already define that in your rvxt ? (for me it just kills copy mode) .<br />
<br />
I guess I am looking for a very Emacs like shell, without running shell in Emacs...
  </content>
</rdf:Description>
</rdf:li>

<rdf:li>
<rdf:Description rdf:about="#1198015394.84">
  <dc:source> http://snarfed.org/ </dc:source>
  <dc:title> Emacs keybindings in GNU screen's copy-scrollback mode </dc:title>
  <dc:creator> Len </dc:creator>
  <dc:date> cmt_pubDate </dc:date>
  <dc:format> text/html </dc:format>

  <content>
    Since I use C-a all the time in emacs, I've mapped screen's control key to ` (same key as tilde, but no shift press needed), using:<br />
<br />
escape ``<br />
<br />
I also have jumping to start and end of buffer during scrollback with:<br />
<br />
# M-&lt; and M-&gt; for start/end of buffer&nbsp; <br />
bindkey -m "^[&lt;" stuff "g"&nbsp; <br />
<br />
bindkey -m "^[&gt;" stuff "G"
  </content>
</rdf:Description>
</rdf:li>

  </rdf:Seq>
</rdf:Description>
</rdf:RDF>
