Currently when I want to go into scroll mode I press Ctrl+b
and then [
. However after entering copy-mode, I must use the up and down keys to scroll up or down. I would prefer to k
for up and j
for down.
How do I change the scrolling behaviour so that scroll down happens when I press k
and scroll up happens when I press j
?
Scrolling with keys is enabled by default in Tmux. Just press ctrl + b then [ to move around with the arrow keys. Just as with the mouse settings you have to add them to your . tmux.
Scrolling Up and Down in Tmux If you want to scroll the Tmux terminal, enter the copy mode by pressing the “Ctrl+b” combination and entering “[”. Now, you can use the navigation keys like arrows (up and down) for moving line by line. Left and right arrows can be used for character by character moving.
Tmux uses the keybinding 'Prefix' followed by 'Ctrl+o' to cycle around the panes. When you use this key-binding for the first time, it moves the pane in one position clockwise.
The SSH shell session uses a fork of tmux (https://github.com/tmux/tmux) which is a Terminal multiplexor program called tmate (https://tmate.io/) and with it you can open Windows, scroll through history, and more. To quit the history scroll mode, you simply press the letter q.
I use a .tmux.conf
file with something similar to the following, which I adapted to your question
# Set tmux to Vi mode
set-window-option -g mode-keys vi
# Scroll up/down with j/k
bind-key -t vi-copy 'j' page-up
bind-key -t vi-copy 'k' page-down
Although this seems unnecessary because in vi mode, the hjkl
work as expected, and you scroll up/down with J/K
(Shift+J, Shift+K) which work just fine
To make it even more Vim-like I add following:
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
Which works like Vim's visual select and yank
Note: After configuring the file you have to reload it, e.g. with the tmux command :source ~/.tmux.conf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With