Hot answers tagged

32

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


17

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

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


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


6

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; you just have to loop over all visible windows and create a new popup window displaying the window number. The closest thing you can get, which may actually be ...


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


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

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 window) to scroll as close to N lines as possible due to the wrapped lines, then moves the cursor back to the original relative line position in the Vim window. ...


5

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


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


5

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

You are looking for Choosewin, sadly it's not being actively developed anymore, but for the simplest use cases it works great.


4

Assuming you have set mousemodel=extend it's simply <RightMouse>.


3

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


3

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


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=


3

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


3

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 (respectively) will fix the problem. The escape sequence terminal emulators send when they gain focus is \<Esc>[I. When the ttymouse vim option has been cleared, ...


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

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


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

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 cursor to that location. If you don't want the cursor to move, put the following in your vimrc: augroup NO_CURSOR_MOVE_ON_FOCUS au! au FocusLost * let g:...


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.


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