18

After performing a keyboard shortcut in tmux (I am not sure which), I am put into a state of perpetual copy-mode. I can type normally, but every time I hit the n key it prompts to gotoline input.

If I close the pane it happens even on the new pane I have created.

Any help on how to exit this once it happens would be great, as all documentation surrounding copy-mode states that when you hit Esc or q you should leave copy-mode.

3
  • 8
    Does Ctrl-C work any better?
    – B Layer
    Commented Feb 17, 2018 at 12:38
  • 1
    Dealing with the same problem. Ctrl-C does not resolve it.
    – x1a4
    Commented Oct 20, 2019 at 1:20
  • Ran into the same problem but I just was in capslock.
    – ygorg
    Commented Sep 24, 2021 at 7:35

2 Answers 2

12

Typically I get out of copy mode using Enter. On another machine with different desktop environment and different terminal, this doesn't work in tmux. But I did find a way.

If you look at the definition of the cancel key in copy mode ( Ctrl+c and Ctrl+Esc ) that's defined as

bind-key    -T copy-mode    C-c               send-keys -X cancel

That means you can do Ctrl+b to enter command mode and then execute

send-keys -X cancel

This will take you out of copy mode.

Variation on the theme would be to change your key mode to vi ( unless you already use that or your EDITOR environment variable already set to it):

set -g mode-keys vi

This allows hitting q in copy mode to cancel the said mode


As for how to deal with the problem of n key and gotoline, I can't answer that. I'd suggest trying different terminal emulator or keyboard, since the issue may not be related to tmux at all.

2
  • 4
    As a sidenote, I don't know which version of tmux you're using but in version 2.9a pressing q exits the copy mode and I'm not even using vi keybindings. Also I found out ctrl+c, ctrl+x, ctrl+v to be working (and the keybindings are not even referenced into the help menu). hope it helps.
    – vdegenne
    Commented Jan 22, 2020 at 12:46
  • 1
    I find myself back here after over a year with the same problem (n key / goto line issue), this time with tmux 3.0a. It's definitely tmux, and nothing else that causes this. Still no solution.
    – x1a4
    Commented Jan 4, 2021 at 18:53
1

You can check your current tmux key bindings by running tmux list-keys. If you see a binding that matches

bind-key -T root n <command>

then the n key is bound in the root table. This means that pressing n in the shell at all will cause <command> to be run. You can remove the binding by running

tmux unbind -T root n

I ran into this issue while using the tmux plugin tmux-copycat, which adds some alternative bindings for copy/paste functionality. Following the above instructions resolved it.

1
  • in my case also it was related to this plugin.
    – iconoclast
    Commented Sep 20, 2021 at 22:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .