1

Where ever I say vim, its vim inside tmux.

Current scenario: I have mouse disabled in vimrc and enabled in tmux.conf. Mouse scrolls inside vim, use tmux-mouse to scroll and thus scrolls through history.

Case-1
If I disable mouse in tmux also (vim=off, tmux=off), then scrolls result in movement of cursor (cursor-positioning) in vim in tmux.

Case-2
If I enable mouse in vim also (vim=on, tmux=on), then I face problems with copying, which I don't want. So my requirement is to keep mouse off in vim.

The target is to use scrolling in tmux only, while in vim scrolling should move the cursor (which kind-of scrolls when the cursor reaches the edge of page, which is the default configuration).

My question is that is there a way to set the behavior so as to disable mouse scrolling in vim (so that the default behaviour works, ie scrolls move the cursor) when I enter vim in tmux, only in the pane which has vim and re-enable it when I exit vim.

In more simpler terms, keeping tmux=on, vim=off, turn off the effects of tmux=on in vim and thus scrolls result in cursor positioning.

0

2 Answers 2

2

I used this plugin: tmux-better-mouse-mode and turned on this flag in .tmux.conf:

set -g @emulate-scroll-for-no-mouse-alternate-buffer "on"

This worked exactly the way I required.

1
  • The only way I could find to make it work.
    – Ripley
    Commented Sep 9, 2022 at 0:32
0

This question is very poorly worded.

It is not clear whether you want the mouse to work in vim or not.

If you do, you just need to configure vim to turn it on - if you do, then tmux will send mouse events in the pane running vim to vim rather than handling them itself.

If you don't want the mouse to work in vim, it should be enough to turn it off in vim. That means vim will not request the mouse from tmux and so tmux will not send mouse events to the pane.

3
  • I have completely re-written the question. Please have a look. Commented Feb 5, 2020 at 14:13
  • 1
    Sounds like if the running application does not request the mouse, then your terminal sends Up and Down keys. This is a feature of the terminal, not of vim. You can configure tmux to do this also, there is an example here github.com/tmux/tmux/issues/1320#issuecomment-381952082. Commented Feb 5, 2020 at 14:52
  • Yeah, this is exactly what I needed. But I found another solution too. I will be posting that here. Commented Feb 6, 2020 at 6:46

You must log in to answer this question.

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