Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim copying the line numbers?

I am using vim through and SSH connection. I have the numbers setting set, and so when ever I try to copy sections of my code with the mouse...it grabs the numbers also. Is there a good way to copy text that doesn't grab the numbers with it. (I know that with in that instance of vim I can use Y, but I need a way to copy to other instances and programs).

Here's an example of what I am talking about.

1 function foo ( home, ip, hash, regex )
2 {
3 return false;
4 }

Thank you all very much for the advice.

like image 788
Eman Avatar asked Nov 30 '22 22:11

Eman


2 Answers

Toggle the 'number' setting with a !

:set nu!

Run it once to turn off 'number'. Run the command again to turn the setting back on.

I use the following mapping in my ~/.vimrc:

nnoremap <leader>tn :set nu! nu?<cr>

It will toggle the setting and then echo out the current value of 'number'

For more help see:

:h 'nu'
:h :set-!
like image 89
Peter Rincker Avatar answered Dec 05 '22 00:12

Peter Rincker


:set nonumber

copy what you want

:set number

:help number

like image 43
gpojd Avatar answered Dec 05 '22 00:12

gpojd