Reputation: 338
To use command :set number
in vim can add numbers at the beginning of the every line.
But the line number is not part of the line contents ,when you copy the contents ,the line number will not be in it ,how can i create the line number ,and make it be the part of the line content ,you can copy and paste the number with every line?
Upvotes: 0
Views: 137
Reputation: 195269
I believe that you are looking for this line:
:%s/^/\=line('.').' '/
this will add line number to each line of text. note:
if you are on linux box, you may consider to use other tool(s) to get line-numbered text output, without changing your original text, like:
nl file
cat -n file
awk '$0=NR" "$0' file
.....
Upvotes: 6