Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1155
  • Last Modified:

copy code and line numbers in visual studio 2010

Hi experts,

I'm using VB in Visual Studio 2010.

I turned on the line numbers in my VB text editor by going to Tools - > Options and checking the Line Numbers check box.

So now when I'm writing vb code on the left i see the line numbers and my code to the right of each line number.

If I select my code and right click my mouse and click copy that copies my code and then I can paste it in notepad or Microsoft Word when I need to write some notes. But I notice the line numbers aren't copied.

Is there a way to select both my code and the line numbers so I can copy and paste them both in notepad or word?
0
maqskywalker
Asked:
maqskywalker
1 Solution
 
Anuradha GoliCommented:
There is an addon supported in visual studio to copy syntax highlighting and line numbers .Download it from the link http://copysourceashtml.codeplex.com/
It is version for VS2008 ,you need to make some changes to support VS2010.
Download latest CopySourceAsHtml msi and install it

1.By default it will be installed to C:\Users\<username>\My Documents\Visual Studio 2008\Addins
2.Create a folder named Addins under C:\Users\<username>\My Documents\Visual Studio 2010 and copy CopySourceAsHtml.AddIn here.
3.Modify Line #5 and #9 change <Version>9.0</Version> to<Version>10.0</Version>
4.Launch Visual Studio 2010 –> Tools –> Addin Manager, if you see CopySourceAsHtml shows up, then it’s enabled successfully.
Copy as HTML6.Now you can select the code and get html by clicking Copy As Html
Right click
This is an example. CopySourceAsHtml also provides options to show/hide control line number, word wrap and so on.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace HelloWorld
7 {
8 class Program
9 {
10 static void Main(string[] args)
11 {
12 // My first application
13 System.Console.WriteLine(“Hello, World!”);
14 }
15 }

Open in new window


Hope this will help you with your requirement.
0
 
Rahul AgarwalTeam LeaderCommented:
0
 
SriVaddadiCommented:
Line numbers are just display only. They r not part of url code and cannot copy as is I.e. with out any add ons.

Also once you copy the code if u paste it to a text editor which supports line numbers u shod see the line numbers. One such editor is textpad. I m sure there r many more out there.

Notepad does not show line numbers though it supports goto line number feature

So IMHO there is no need get fancy by installing some plug ins to just copy line numbers.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now