Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to disable autoselect in Vim

📅 2014-May-20 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ autoselect, clipboard, vim ⬩ 📚 Archive

When you visually mark or yank any text in terminal Vim, you may find that it is copied to the clipboard in your desktop. In GUI Vim, you may find that any text you mark with the mouse is also copied to the desktop clipboard. (This is different from marking and then explicitly choosing Copy from the toolbar). This is true for most modern compilations of Vim which are compiled with the +xterm_clipboard feature. This behavior of Vim is called autoselect.

If you use a clipboard manager, like Diodon for example, you may find that any editing session in Vim quickly overwrites everything in the clipboard manager. Thankfully, this autoselect behavior of Vim can be turned off.

To disable the automatic selection and copying of text in terminal Vim, add this line to your vimrc file:

set clipboard-=autoselect

To disable the automatic selection and copying of text in GUI Vim, add these lines to your vimrc file:

set guioptions-=a
set guioptions-=A
set guioptions-=aA

Tried with: Vim 7.4 and Ubuntu 14.04