Solved

copy code and line numbers in visual studio 2010

Posted on 2012-04-09
3
1,044 Views
Last Modified: 2012-04-10
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
Comment
Question by:maqskywalker
3 Comments
 
LVL 12

Accepted Solution

by:
Anuradha Goli earned 500 total points
ID: 37826723
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
 
LVL 13

Expert Comment

by:agarwalrahul
ID: 37826967
0
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 37827106
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question