2

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?

3
  • Your terminal emulator might let you do block selection, that could be a workaround.
    – Eroen
    Apr 19, 2012 at 22:26
  • Wow. I never realized that works. It looks like ctrl-dragging does block selection.
    – amcnabb
    Apr 19, 2012 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, 2015 at 11:58

2 Answers 2

1

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

Copying:

  • 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

Pasting:

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

0

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

1
  • 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, 2012 at 22:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .