If I select text from command-line vim and copy it to the clipboard, it includes line numbers (from set relativenumber). Gvim is smart about selection and does not copy the line numbers. However, if I do set mouse="" in gvim, it makes it behave like command-line vim (line numbers are copied).

I don't want to enable the mouse in gvim because I don't like the cursor moving when I click. Is there any way to disable the mouse in gvim without making copying to the clipboard grab line numbers?

  • Your terminal emulator might let you do block selection, that could be a workaround. – Eroen Apr 19 '12 at 22:26
  • Wow. I never realized that works. It looks like ctrl-dragging does block selection. – amcnabb Apr 19 '12 at 23:00
  • excellent, just wanted to know how to switch the mouse off - the only thing I've found annoying switching from vim to gvim - I like being able to use it to scroll but accidentally moving the cursor when clicking is annoying – JonnyRaa May 14 '15 at 11:58

Yes. Use Vim as it's supposed to be used: with the keyboard.

Visual selection:

  • v character-wise

  • V line-wise

  • See :help visual-mode


  • y places selected text in the default register

  • "*y places selected text in the * register (the GUI clipboard when available)

  • See :help registers, :help yank


  • p puts the content of the default register after the cursor

  • "*p puts the content of the * register after the cursor

  • See :help put

You won't paste line numbers if you use Vim correctly.


So your problem is basically that you copy the line numbers? Why don't you just add a mapping to toggle your line numbers?

Something like this for example:

map <Leader>nn :set relativenumber!<CR>

Then you wouldn't need to copy the line numbers in the first place...

  • Right now I have to toggle paste mode before I paste, and this would mean I would have to toggle "copy" mode, too. It's better than nothing, but it would be ideal if there weren't a manual step. – amcnabb Apr 19 '12 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.