Solved

copy code and line numbers in visual studio 2010

Posted on 2012-04-09
3
1,027 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

803 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