user1081168
user1081168

Reputation: 59

How to copy entire file to clipboard together with line numbers in Vim

I enabled vim-gtk, opened a file, did :set nu, but the command :%y+ does not copy the line numbers to the clipboard.

That may be resolved in visual mode (I do not know how to use it), but sometimes files are very long and I guess it is impractical.

Also does :set nonumber have a shorter alias like :set number has :set nu?

Upvotes: 0

Views: 207

Answers (2)

Dmitry Alexandrov
Dmitry Alexandrov

Reputation: 1773

To copy the entire file with line numbers to the "+ register (which is CLIPBOARD buffer under X11) you may use:

:redir @+ | silent %# | redir END

Upvotes: 3

jherran
jherran

Reputation: 3367

:set nonumber is the same as :set nonu.

Line numbers will not be copied. But, if you copy the entire file, just enable line numbers where you paste in.

Upvotes: 1

Related Questions