Solved

copy code and line numbers in visual studio 2010

Posted on 2012-04-09
3
1,002 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
Comment Utility
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
Comment Utility
0
 
LVL 16

Expert Comment

by:SriVaddadi
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now