Vim enters into visual mode on selecting text after El Capitan update - vim

Issue is what the title says. Earlier I used to copy text from text files open in vim simply by selecting text and doing Ctrl + C. But now it puts me into visual mode, thus not allowing to copy the text. Its really annoying. Anybody knows any fix for this.
Thanks.

You probably have the mouse mode active. You can turn it off with:
:set mouse=
And turn it back on with
:set mouse=a
If you are using iTerm, you can leave mouse mode on all the time if you want, and hold Option when you want to select without using visual mode. I am not aware of a way to do that in OS X Terminal.
Update (from Younes in comments): For Terminal.app on El Capitan, press the Fn key to bypass the mouse mode. See this question for more.

Related

is it possible to disable mouse visual mode in vim?

I have a problem that when I use my mouse to focus on my vim window, I often end up in Visual mode. However, I like many of the mouse functions such as resizing windows and selecting tabs.
Is there any way to leave mouse mode enabled, but disable the mouse's ability to enter Visual mode when accidentally selecting text?
Try this in your $HOME/.vimrc configuration.
set mouse=nicr
Or if you want to use on the fly in vim , try with command mode :set mouse=nicr
For some user's set mouse-=a also works, but that is not working for me.

How to stop Vim from writing onto system clipboard when visually selecting texts

I am using Vim 7.4.423 on a Windows 7 machine.
I notice that Vim will copy to system clipboard of whatever texts that I have "highlighted" through Visual mode. Is there a way to stop him from do this?
The "overwriting of clipboard upon enter visual mode" does not differ whether I use mouse click or the V/v operator. Nothing on the system clipboard will be left once I enter the visual mode.
PS: I did not find mswin in my _vimrc.
Thank you!
This sounds like you either have an 'a' in your 'guioptions' option, or you have "autoselect" in your 'clipboard' option.
Check the output of this command to see which is the case and then fix it accordingly:
:verbose set clipboard? guioptions?
Solution, thanks to Ben's advice on guioptions.
Remove the following line:
set guioptions+=a
And make sure that <C-C> is behaving "normally". (Normally as for windows OS.)
vnoremap <C-C> "+y
The second mapping means to "feed onto system clipboard".

Selection automatically put into X11 clipboard - VIM

In my previous Linux install, when I selected some text in visual mode (without the mouse!), it would automatically put it in my X11 clipboard. Then I could naturally paste this text anywhere else using the mouse middle button.
With my new Linux installation, this doesn't work anymore (merely selecting text in visual mode doesn't put it in X11 clipboard anymore).
How can I get this nice feature back?
(I am not interested into the "*y or "+y solutions, which by the way don't work on my system.)
Thanks in advance!
The visual selection (v, V, or CTRL-V) can automatically be copied to the
X11 selection (* buffer).
In non-gui mode the clipboard option controls this (only supported if
+xterm_clipboard appears when you type vim --version). In gui mode
guioptions controls it.
This makes all Visual mode selections automatically go to the X11 primary
selection:
set clipboard+=autoselect
set guioptions+=a
This turns it off:
set clipboard-=autoselect
set guioptions-=a
In vim see:
help 'clipboard'
(single quotes required)
Use:
set guioptions+=a
This works with the GUI (Gvim). Reference is at :help guioptions_a.
*guioptions_a* *'go-a'*
'a' Autoselect: If present, then whenever VISUAL mode is started,
or the Visual area extended, Vim tries to become the owner of
the windowing system's global selection. This means that the
Visually highlighted text is available for pasting into other
applications as well as into Vim itself. When the Visual mode
ends, possibly due to an operation on the text, or when an
application wants to paste the selection, the highlighted text
is automatically yanked into the "* selection register.
Thus the selection is still available for pasting into other
applications after the VISUAL mode has ended.
If not present, then Vim won't become the owner of the
windowing system's global selection unless explicitly told to
by a yank or delete operation for the "* register.
The same applies to the modeless selection.
When using Vim inside gnome-terminal on Arch and Gentoo Linux this functionality just works.
When using Vim inside Konsole this does not work.
Using gvim -v will launch a terminal version of GVim where set guioptions+=a works:
any text selected within that Vim is automatically copied to Linux's selection buffer.
To paste text from the selection buffer press the middle mouse button
On my Debian I got it working after installing vim-gnome package.
A comment from pkg-vim-maintainers mailing list instructs to install either vim-gtk, vim-gnome or vim-lesstif.
With my new installation of Kali, I solved the issue above by installing vim-gtk package for gnome-terminal. The vim-gtk package changes the "-xterm_clipboard" to "+xterm_clipboard", and the problem is solved. After selecting text in vim, the text will be copied to system clipboard automatically.

edit gvim mouse buttons

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.

vim -- copy to system clipboard in OpenSuSE

I've tried the methods mentioned at Vim: copy selection to OS X clipboard, but neither the * or + register seem to be working for me. I'm on OpenSuSE 11.3, and have vim and vim-data installed (there is no vim-full package as mentioned in the link in SuSE). I've tried with Klipper enabled and disabled. (edit) I've also tried pasting with ctrl+v and middle click.
Thanks in advance.
See if you have something called vimx, an X enabled version of vim. You can alias vim to that, and then use * register.
This is a superuser question.
I presume that you are running VIM in terminal and talk about VIM's visual selection, not selection with the mouse in terminal window.
Since in your case VIM isn't aware of the X, it obviously cannot communicate your selection to the X Window System. If you select something in terminal window with mouse, then you are selecting not in VIM, but in the terminal emulator which is aware of the X and communicates properly the current selection to X's clipboard.
You can try to play around with xsel tool which allows one to access the X clipboard from command line. You would need to override the usual clipboard shortcuts to not only put the content of the visual selection into the usual VIM register(s), but also to pipe it to the xsel so that it becomes the new X selection. (Strangely enough, I do not have the xsel installed on the SLES10 system I have right now at hand.) That obviously would only work if (1) the terminal is running locally or (2) remote server you are connected to allows the X forwarding. If the X forwarding is disabled on the server where you edit the files, then you have no chance to do in VIM: only selecting with mouse in terminal window would work.
Check synchronize contents of the clipboard and the selection in the clipper configuration.
Highlight text with the mouse (will not work with vim key selections).
Your selection is in the clipper.

Resources