Hot answers tagged

11

As @Doorknob said in his comment, :set mouse=a fixes the problem.


9

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


7

You should add the following two lines at the end of /etc/vim/vimrc : set mouse= set ttymouse=


7

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 =)


6

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 `:exe` because I didn't want to use `:if` in a command definition which would look like: :command! ToggleMouse if empty(&mouse) | set mouse=a | else | set ...


5

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 certain terminals (xterm, MS-DOS, Win32 |win32-mouse|, QNX pterm, *BSD console with sysmouse and Linux console with gpm). I use tmux a lot, so $TERM is set ...


5

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 current cursor position "mark a is the previous cursor position norm mb let currPos=line('.') norm `a let prevPos=line('.') if currPos>prevPos ...


5

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 'foldcolumn' is a number, which sets the width for a column on the side of the window to indicate folds. When it is zero, there is no foldcolumn. A normal ...


5

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's all about the features that are enabled with your install of Vim. In OS X and Linux, the clipboard feature needs to be enabled, and Linux usually also ...


4

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 distinguish between your "number" or gutter. gVim "emulates" a terminal emulator in many ways, and acts in the same way. Then enabling the mouse, it's Vim that does ...


4

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 particular selection or chunk of text. Like all other Vim commands, you can think of y as a verb and give it modifiers, like y2j to yank the current line and the next ...


4

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 have put the following code snippet in your .vimrc: nnoremap <S-ScrollWheelUp> <ScrollWheelLeft> nnoremap <S-2-ScrollWheelUp> <2-...


4

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 remap. So, you could get the behaviour you describe by :nmap <ScrollWheelUp> h :nmap <ScrollWheelDown> l Note that I'm using nmap for mapping in ...


4

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: After the comment by @jjaderberg below, I decided to clarify why I assumed that xterm_clipboard in vim is Primary. To be sure I looked up Clipboard definition ...


3

EDIT: One problem with my original function is that you get annoying lag when using it at near the top/bottom of the document (the cursor tries to scroll up from line 1), and that the cursor does not move at all when near the top/bottom of the document. The updated version below fixes these issues and makes scrolling more similar to the behavior of Ctrl-U ...


3

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 slm=


2

OK. So this does not use the mouse. But that's the whole point of vim (not needing to use the mouse). You can use the vim normal copy command (which will not select the line numbers). To get it into the system clipboard just use the buffer * "*<Normal Yank Command> You have now yanked the text you want into the system clipboard and it can be pasted ...


2

If you use MacVim on OS X, this will work with a trackpad: set mouse=n " enable mouse in normal mode set nowrap " disable line wrapping (so there's something to scroll to)


2

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/985865#985865 (If you are not using a Mac and you are having a similar issue, you can use ctrl-z to suspend vim. Once you are done doing whatever, execute the ...


2

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 sure my configuration wasn't affecting anything, then executed :set mouse=a. I entered some text into vim, then selected some of it with the mouse, then pasted it ...


2

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 the click was initiated.


2

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 mouse= autocmd FocusGained * call timer_start(200, 'ReenableMouse') augroup END function ReenableMouse(timer_id) set mouse=a endfunction Note that this ...


1

The behaviour you request is essentially impossible to achieve in Vim, because of two immutable facts: When in visual mode, the cursor is always at one end of the selection. With the exception of jumping to the other end of the selection by pressing o, if you move the cursor, you are by definition altering the selection, The cursor is always visible on ...


1

As LEI commented, the problem resided on my terminal, and it didn't have anything to do with vim. Changing the corresponding parameters of my terminal fixed the issue.


1

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 might help.


1

This is only a partial solution at best, but you can globally disable the mouse/touchpad while vim is running with xinput in a shell script: xinput set-prop $ID "Device Enabled" 0 And then xinput set-prop $ID "Device Enabled" 1 When you're ready to have the touchpad work again. Use xinput --list to get the id of your pointing device.


1

The use of the mouse is controlled (as you find out) with the mouse setting. It is activated only if mouse is equal to "something". This something determines when is the mouse used. To disable the mouse you can simply: set mouse= Also in your function, you can call the set command directly: function! EnableMouseFunction() set mouse=a endfunction


1

How about nnoremap <ScrollWheelUp> k nnoremap <ScrollWheelDown> j ? I can't test on osx though, but it works on my linux installation.


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