So if I am in Tmux and a bunch of output came to the terminal, I can scroll through it by pressing:
ctrl-b [
Now, I have to pick my hands up and go to the arrow keys to scroll up.
How do I map the vim keys in scroll mode?
In Tmux, you can scroll up and down by using the following methods: Press the Ctrl + B keys, then the subsequent “[]” key. To navigate the Tmux interface, use the standard keyboard navigation keys such as up/down arrows, page up/page down, etc.
Once vimux is installed, you can access the command prompt from within vim by running :VimuxPromptCommand . You can then immediately start typing your shell command. Pressing enter will run the command in a tmux pane in the current window. If necessary, vimux will create a new pane for the command to run in.
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.
Update in 2020: I don't think anyone should be using any version of tmux below 2, so the concise configs for modern tmux is just
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi V send -X select-line
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
Previous answer
Unsure which tmux you have. This works for both 1.8 and 2.6, which are the two I'm forced to use.
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | cut -c 6-)"
if-shell -b '[ "$(echo "$TMUX_VERSION < 2.4" | bc)" = 1 ]' \
"setw -g mode-keys vi; \
bind-key Escape copy-mode; \
bind-key -t vi-copy v begin-selection; \
bind-key -t vi-copy V select-line; \
bind-key -t vi-copy y copy-pipe 'xclip -in -selection clipboard'"
if-shell -b '[ "$(echo "$TMUX_VERSION >= 2.4" | bc)" = 1 ]' \
"set-window-option -g mode-keys vi; \
bind-key -T copy-mode-vi v send -X begin-selection; \
bind-key -T copy-mode-vi V send -X select-line; \
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -in -selection clipboard'"
The relevant section here for hjkl is just setw -g mode-keys vi
for 1.8 and set-window-option -g mode-keys vi
for 2.6 (these might even be aliases and work in both versions, not sure). That being said, the v
and V
mappings with xclip
are definitely useful.
To supplement the accepted answer, I found the following .tmux.conf
lines accomplished most of what I needed:
set-window-option -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
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