Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

40 votes

Fully disable mouse in console vim

You should add the following two lines at the end of /etc/vim/vimrc : set mouse= set ttymouse=
user avatar
20 votes
Accepted

Scroll the screen, not the cursor, when using scrollwheel

As @Doorknob said in his comment, :set mouse=a fixes the problem.
user avatar
  • 1,037
9 votes
Accepted

How can I disable all mouse functions in MacVim?

To disable all mouse functions, you can simply put this in your vimrc file: set mouse= For more, see :help 'mouse'.
user avatar
7 votes
Accepted

Console vim(x): Can I map the scroll wheel to undo--redo?

it works for me: set mouse=a map <ScrollWheelUp> u map <ScrollWheelDown> <C-R> But i hope this is just for fun. Must be horrible =)
user avatar
7 votes
Accepted

Can I use the mouse for folding/unfolding in Gvim?

Credits to Ingo Karkat, you just need to set foldcolumn for using the mouse to open and close folds. From :he fold-foldcolumn: FOLDCOLUMN fold-foldcolumn ...
6 votes
Accepted

How to select and copy lines to clipboard which are selected by mouse without linenumbers and gutter?

The trick is to enable the mouse with :set mouse=a. By default, Vim doesn't handle the mouse; the terminal emulator does, and from the terminal emulator's perspective "it's all text", it can't ...
user avatar
6 votes
Accepted

Can I scroll in vim with my touch screen?

Note: I have not tested this with gvim, only with normal vim This piece of code allows me to scroll instead of selecting text when I drag using my mouse. function! MouseScroll() "mark b is the ...
user avatar
  • 333
6 votes
Accepted

disable previously enabled mouse with Vim script

You don't need anything that complex set mouse=a " and set mouse= are enough. You can even define your command to be :command! ToggleMouse exe 'set mouse='.(empty(&mouse)?'a':'') " Here I use ...
user avatar
6 votes
Accepted

Does Vim have functionality similar to tmux's `display-panes` command for selecting (goto) a specific window by number?

I'm not aware of any Vim feature or even plugin that does that; in fact, up until recently it would be rather hard to display it like that, but with Vim 8.2's popup windows it wouldn't be too hard; ...
user avatar
5 votes

What's the difference between the "clipboard" and "xterm_clipboard" features?

I want to take a shot at answering my first question on this forum. If I understand your question right, you are referring to concepts of "clipboard" and "primary". If not - sorry, I am wrong. Note: ...
user avatar
5 votes
Accepted

Can I use the mouse scroll wheel to browse the auto-completion popup menu?

Your examples work fine for me on Vim 7.4.1689 and Neovim. The following didn't work at first: set mouse=a Then I read the following in :h 'mouse' Enable the use of the mouse. Only works for ...
user avatar
  • 6,320
5 votes
Accepted

Visual scrolling/visual <C-e> and <C-y> across wrapped lines?

I've released a vim plugin that pretty closely matches this behavior. Instead of scrolling by exactly N lines, this maps <C-u>, <C-d> (half window) and <C-j>, <C-k> (quarter ...
user avatar
  • 1,247
5 votes

Can visual select mode be integrated with the Unix selection clipboard?

I understand that you are set up with the features necessary for copy and pasting with the system clipboard, but I want to be a tad redundant as those registers can be a tad challenging to set up. It'...
user avatar
  • 491
5 votes
Accepted

Visual block selection using mouse in Neovim

Assuming you have set mousemodel=extend it's simply <RightMouse>.
user avatar
  • 15.5k
4 votes

How to select and copy lines to clipboard which are selected by mouse without linenumbers and gutter?

A good general rule when using Vim is to not use the mouse—Vim is designed from the ground up to be used with keyboard commands. In order to copy text, you can use the y command to yank a ...
user avatar
  • 1,200
4 votes

How can I use my trackpad for horizontal scrolling?

I figured out a way to do that with Hammerspoon and clever usage of mapping. The first part is configuring Shift + ScrollUp and Shift + ScrollDown to scroll horizontally. In order to do that, you ...
user avatar
4 votes

How can I use my trackpad for horizontal scrolling?

According to :help scroll-mouse-wheel the answer is no if you are using the Win32 GUI. On the other hand, using X11 GUI or console vim with mouse support, the wheel sends key presses that you can ...
user avatar
  • 7,992
4 votes

Does Vim have functionality similar to tmux's `display-panes` command for selecting (goto) a specific window by number?

You are looking for Choosewin, sadly it's not being actively developed anymore, but for the simplest use cases it works great.
user avatar
  • 1,902
3 votes

How to disable moving the cursor with the mouse

From Vim Tips Wiki: When you are using another application and select go back to Vim by clicking inside Vim's text area, it not only switches application focus to Vim, but it also moves the ...
user avatar
3 votes
Accepted

How to disable moving the cursor with the mouse

Here's a heavy solution: nnoremap <LeftMouse> ma<LeftMouse>`a It will let the click go through (thus changing the focus), but make sure the cursor always goes back to where it was before ...
user avatar
  • 7,406
3 votes
Accepted

How can I use mouse=a for local and remote work?

It works for me. I have ForwardX11 yes in my ~/.ssh/config file, which should have the same effect as running ssh with -X, and I started vim on the remote machine as vim -N -u NONE -i NONE to make ...
user avatar
  • 5,854
3 votes
Accepted

Cancel mouse highlight on mac

You can use fn to bypass Mouse Reporting for programs like vim. (i.e. do fn+left-mouse button to clear the selection.) Source: https://superuser.com/questions/125102/mac-os-x-terminal-mouse-support/...
user avatar
3 votes
Accepted

How to keep Vim from exiting Visual Mode due to mouse clicks while mouse=a?

You could do this: :xnoremap <LeftMouse> m`<LeftMouse>v`` This allows you to click on where you want to extend the visual selection to, rather than drag. It works best if you also :set ...
user avatar
  • 16.5k
3 votes

Scroll the screen, not the cursor, when using scrollwheel

I know this is a few years late, but you can use nmap <Down> <C-e> nmap <Up> <C-y> This worked for me.
user avatar
3 votes

Fully disable mouse in console vim

This might work if you put it at the end of your .vimrc set mouse=c It's probaly not Vim that takes the mouse input, but rather your Terminal-emulator. To disable mouse support on your terminal this ...
user avatar
3 votes
Accepted

How to use "FocusGained" to stop my cursor from moving

I guess mouse clicks don't update the jump list. (:help jump-motions seems to confirm this is the case.) Try this, for the async solution: augroup MouseHack autocmd! autocmd FocusLost * set ...
user avatar
  • 27.4k
3 votes
Accepted

Mapping Ctrl + mouse click

You are looking for this which I found at the bottom of :h keycodes: nnoremap <C-LeftMouse> :echom 'Foo'<CR> And according to :h <LeftMouse> you also need to check that set mouse ...
user avatar
  • 45.9k
3 votes

Focus follow mouse

In GVim there are set mousefocus and set scrollfocus (only Windows GVim 8.1.2257 or later). mousefocus automatically activates window so it gets both mouse and keyboard input; scrollfocus only ...
user avatar
  • 15.5k
3 votes

Why has vim started launching the ilist on FocusGained?

This appears to be a genuine bug in vim, which was fixed by the patch 8.2.2428. Both the Arch and Debian packages have now been updated to include this patch, so pacman -Syu or apt-get upgrade (...

Only top scored, non community-wiki answers of a minimum length are eligible