I use Vim to edit text files on Linux. Commonly I connect to remote Linux machines using PuTTY from Windows. I use GNU Screen commonly as well. When using Vim inside Screen I am unable to use the Page Up key because Screen interprets it as a command to start copy mode.

I would like to use Page Up for its regular up-paging functionality. How can I configure Screen to do this?

  • log-in to system as you usually do and type: echo $TERM I'm using PuTTY and connecting to my Linux and able to use PAGE-UP no problem.
    – alexus
    Aug 27 '12 at 19:51
  • 3
    you have to configure putty as answered in this thread: superuser.com/questions/94436/…
    – jfried
    Aug 27 '12 at 19:52
  • 1
    In Vim, page up can also be achieved using ctrl-u (ctrl-d for page down). Not that that solves your problem...
    – adamdunson
    Oct 25 '12 at 6:27
  • 1
    Ctrl-U and Ctrl-D only scroll a partial screen. You can use Ctrl-B and Ctrl-F for full screens. Dec 8 '12 at 20:30

Put this in your .screenrc:

bindkey "^[[5~" eval "copy" "stuff ^b"
bindkey "^[[6~" eval "copy" "stuff ^f"

This will make PgUp and PgDn enter copy mode and move by pages within screen's scrollback buffer.

Caveat: You still need to hit Esc to exit screen's copy mode.

  • 1
    Thanks! FYI, I also bind "^[[5;2~" and "^[[6;2~" because my terminal uses SHIFT page up/down, so my fingers hit that naturally.
    – Jeff Ward
    Sep 10 '20 at 16:32
  • @JeffWard PG UP / PG DOWN works, but not SHIFT PG UP / SHIFT PG DOWN from my Putty / SSH terminal. Not a big deal, PG UP / DOWN is already great!
    – Basj
    Jul 28 '21 at 13:31
  • SHIFT + PgUp/PgDn are the default keyboard combinations for scrolling terminal lines (at least the server and remote consoles I'm using work this way). Getting the same behavior using screen makes life easier. +1 @Jeff Ward, the ANSI code "2" for SHIFT is really hard to find I also want to confirm that it worked!
    – linux64kb
    Jan 10 at 18:43

check your personal or system-wide screenrc files, search things like eval "copy". If it exists, try to comment it out and see if it helps or not.

As far as I know, Page Up is not bind to start copy mode by default in screen. I suspect that this behavior is due to some settings specific in your remote system. I personally bind F9 and F10 to scroll up and down in the copy mode and left other keys to programs running in screen:

bindkey -k k9 eval "copy" "stuff ^u"
bindkey -k k; eval "copy" "stuff ^d"
bindkey -m -k k9 stuff ^u
bindkey -m -k k; stuff ^d
  • 3
    ^u and ^d only scroll a partial screen. You can use ^b and ^f for full screens. Dec 8 '12 at 20:28
  • Could you please explain what -m and -k does? I've searched for "man bindkey", but I get "the shell built in command blah blah" answer but it's not explained anywhere :(
    – linux64kb
    Jan 10 at 19:03

I preferred the answer from superuser:

Add the following to your ~/.screenrc:

termcapinfo xterm ti@:te@
termcapinfo xterm-color ti@:te@


termcapinfo xterm* ti@:te@

Scrolling back feels a bit weird because it seems to scroll all windows at once and screen disappears completely if you go back too far but for me that was far the best solution because I don't need to instruct the user to use another shortcut than the well-known Shift+PgUp / Shift+PgDown.

Update: It seems that this solution skips some parts of the output when scrolling. So I cannot recommend it anymore. But I leave the answer here for completeness.

  • 3
    Or: termcapinfo xterm* ti@:te@ for both.
    – kenorb
    Jan 17 '16 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy