In using vim on Linux at the terminal I expect mouse selection to behave as (e.g.):
Start insert mode
Select some other text with left mouse button
Click middle button
Selected text gets pasted in where I was inserting
I think of this as "normal terminal mouse behaviour", and expect it to work like that for all programs, not just vim. However, something changed in the past few days and vim now acts differently:
Start insert mode
Select some other text with left mouse button
My insertion point now moves to the start of the selection
My mode is changed from "Insert" to "(insert) SELECT"
Click middle button
Looks like nothing happened, but I think it has actually pasted the selection on top of itself, because if I click again the selected text appears a second time after the selection.
One other symptom: The mouse cursor is now an arrow when pointing at a vim terminal window. Other terminal windows show an I beam, and vim used to do that too.
This is a problem with vim, not terminal because
It behaves the same in Gnome terminal, Konsole, and Terminator
Other programs at terminal behave the "normal" way
I have tried changing settings for :behave, :set selectmode and :set mouse, but this has not helped (maybe I just haven't found the right combo yet?).
This problem is recent (this week), but I have not changed my vim settings relevantly in that time.
Any ideas as to what's going on here?
The command :set mouse=a suggested should enable mouse integration in all modes but this is not what you want. To stop VIM messing with the mouse settings use :set mouse= (with no letters after the equals) to prevent it from changing the mouse in any mode.
Related
I am using both MacVim and console Vim.
My shell is ZSH and the terminal is iTerm2.
What I am trying to achieve:
when I'm dealing with the GUI, in other window, sometimes I want a quick copy paste from a VIM window.
I can use the mouse to select the text, but:
cmd-c doesn't copy
ctrl-c doesn't copy
ctrl-shift-c doesn't copy
right button context menu copies sometimes but not always and I don't know why. I don't know if it's related to the mode I'm in, etc it's just not reliable. At this stage, the menu that appears in the console is not VIM's, since it doesn't have one, but iTerm2, so things get very confusing.
when using MacVim, the menu shows me to use cmd-c to copy, but whether I do it, or using the context menu it sometimes works and, more than often, it doesn't.
Reading from forums, I've tried to do:
:setmouse=a
but, when I press return it doesn't even acknowledge the line.
So, my simple question is: how can I do quickie copies from a mouse selection in VIM to paste it in another window without have to do anything else that would slow me down?
The command is
set mouse=a
but you need clipboard interfaces. See :help "*
I would visually select (with or without mouse) and use "*y, or :yank * if it can be done linewise (sometimes the range is easier to type, like :%y*).
Alternately, disable mouse-reporting (Cmd-R on mac) and use the native copy-paste.
I am having issues with my vim setup. If I click, or if I scroll with the mouse inside vim, I get a strange behavior. Those actions sometimes change my mode to insert and copy or paste things from the register, or insert random characters.
I do not know when the problem started since I do not use my mouse too often inside vim. However, sometimes I click or scroll on my window, and these commands are messing up my document.
I am using arch with i3 and uxrvt. I would also share my .vimrc file, but I am new here, so I do not know if I should just copy and paste it.
I noticed that if I open vim with xterm instead of uxrvt, the mouse clicks and scrolls refresh the cursor and place it at the middle of the screen and to the left.
I have set the option set mouse=a in my .vimrc
Please help me :)
Ok, I figured it out what was the issue. At some point, I mapped this command: nnoremap <esc> :noh<return><esc> to disable the highlighted results of a search after pressing <esc>
When reading :h set ttymouse, I realized that the mouse clicks and scrolls return <esc> and some other characters to the editor. This, together with my remapping of <esc> was messing up the return values of my mouse.
I fixed it by removing my remapping of <esc>, but I would like to use that mapping without messing my mouse :(
In both vim or gvim 7.3 I am having a problem when selecting lines from the buffer with my mouse when using vertical splits. If I select lines from one of the vertically split buffers I also end up selecting the lines from the other buffer.
In general I use the keyboard to perform selections but there are certain cases where I prefer the mouse (selecting from a VNC window to cut and paste into a windows ENV, etc.).
I have set mouse= in my .vimrc file so my mouse doesn't move the cursor when I click in a gvim window.
Is there a setting to prevent selections across buffers?
You've disabled the mouse in vim with set mouse= so the selection is being done by your terminal emulator and not by vim. The terminal emulator does not know about buffers or splits in vim and just selects the entire line across the screen being shown.
If you wish to only select from one buffer you will need to enable the mouse in vim but I'm not sure what else you will need to do.
Im getting this sometimes when i scroll up the files im editing.
http://postimage.org/image/ajhrqm3ox/
As you can see the part above is not the file im editing, but the content of the terminal before running vim..:).
If you are attempting to scroll with the mouse wheel and the terminal is capturing it and scrolling back in its own buffer, enable mouse mode, enable the mouse:
set mouse=a
See :help mouse for an explanation of the mouse modes possible, and note that this will also enable positioning Vim's cursor with the mouse, making visual selections, and other expected mouse behaviors.
I have a two part question regarding mouse clicks on gvim.
1.) I would like to change my gvim double left mouse click into something similar to the windows environment (ie Notepad, Microsoft Word), wherein it: highlights the current word, and replaces it with whatever I type. This is akin to pressing 'cw' for changeword in vim.
2.) I would like my single mouse click to place a cursor upon the selected text and enter insert mode. Again like how a mouse normally behaves in Windows.
1) nmap <2-LeftMouse> ciw
You could use viw here, which will visually select the current word, but then you will still have to press c to replace it.
2) nmap <LeftMouse> <Leftmouse>i
Or replace the i with an a if you would prefer to append, rather than insert.
You can use behave mswin or so $VIMRUNTIME/mswin.vim so set up a lot of stuff so that it works more like a regular windows program.
The specific setting you are looking for are:
set select=mouse
this causes the mouse to start select mode instead of visual mode. Select mode causes the selection to be deleted and insert mode to be entered when a printable key is pressed.
As in Prince Goulash's answer
nmap <LeftMouse> <LeftMouse>i
will turn on a sort of click-to-type mode.