VS Macro for deleting line numbers

When you copy code from internet and paste into Visual Studio, have you ever faced the trivial task to remove line numbers in the front of each line of code? I just wrote a macro to do this and I’d like to share it with you.

When we past code into Visual Studio, it often looks like this:


With this macro, we can remove line numbers very quickly. And the following is the script code. It will set the cursor to the start of current opened document, parse the first 3 characters of each line until the end of the document.

    Sub DeleteLineNumber()
Dim objSel As TextSelection = DTE.ActiveDocument.Selection

Dim endLine As Integer = objSel.ActivePoint.Line

For line = 1 To endLine

For bit = 1 To 3
Dim number As Integer
If Integer.TryParse(objSel.Text, number) Then
End If


End Sub

To use this macro, you can

  1. Launch Visual Studio

  2. Press ALT+F8 to open Macro Explorer

  3. Expand MyMacros node in Macro Explorer

  4. Right click a module and select ‘New macro’ to create a new macro.

  5. Past in the script.

And there are several ways to run a macro. They are described in How to: Run Macros. If you find any issue or has any comment, please feel free to let me know


guangming April 25, 2010 at 7:14 PM

Discount Handbags On Sale-Beautycasa Online : Official online destination for all things Louis Vuitton Handbags and purses including Luxury Handbags trends, designer reviews, handbag deals, and more.Hot sale Cheap cell phonesand cell phone china on our site! Fashion look and powerful functions for these mobile phones even discount cell phones! Wholesale HiPhone, 3G cell phones, PDA/Smart Phone now.China Cell PhonesDon't miss these cellphone!toy wholesale

Web Design Firm November 25, 2010 at 3:05 PM

That was good, I got another problem here, but it is due to my own setup.

best electronic cigarette December 3, 2010 at 12:25 AM

Great numbers,Thank you for sharing.I love your blog.Keep on posting.

laptop batteries July 8, 2011 at 11:07 PM

Thank you for sharing!

Web Application Development July 29, 2011 at 5:44 AM

I am impressed by the quality of information on this website. There are a lot of good resources here. I am sure I will visit this place again soon.

Blazer for travel January 30, 2013 at 8:11 PM

Thanks for the brilliant tutorial. I never thought I’d be able to set up Ubuntu, but it happened. I’m quite proud of myself, and grateful to you lol.Thanks you really helped me out! I even got it working!

fdhty April 23, 2013 at 6:43 PM

Pray for powers equal to your tasks.Then the doing of work shall be no miracle, but you shall be the miracleRunescape Gold, Fear not that the life shall come to an end, but rather fear that it shall never have a beginning rs gold, At twenty years of age, the will reigns; Runescape Gold at thirty, the wit; and at forty, the judgment. What gets us into trouble is not what we don't know.It's what we know for sure that just ain't so.

Many people in this life deny their freedom. They sit back in their misery and blame it on their parents, or their childhood, their health, or their financial problems Cheap Minecraft Gift Code, they never once stand up and take responsibility for their own lives and their own happiness Buy Xbox Live Points, of all the wonderful gifts that we've been given, one of the greatest is freedom Ultimate Game Card.

Rahul Roy March 4, 2015 at 3:50 AM

Superb article ,I really appreciated with it, This is fine to read and valuable pro potential,I really bookmark it.thanks
No Addicton Powder
Slim n lift Aire Bra
Step up height increaser
Addiction killer Powder

five nights at freddy's August 7, 2015 at 1:38 AM

I agree with your way of thinking.
facebook móvil | five nights at freddy's download | facebook movil

Anil Gupta March 3, 2017 at 11:59 PM

I am very happy when read this blog post because blog post written in good manner and write on good topic. Thanks for sharing valuable information.
Bangalore Web Designing Company, UI Designing Company Bangalore

kumar March 8, 2017 at 1:58 AM

It was very useful for me and all. Keep sharing such ideas in the future as well. This was actually what I was looking for, and I am very happy to come here. I bookmark your web blog as a result I found superb information on your web blog. I simply want to say that absolutely very good post.
Engineering Colleges, Mechanical Engineering Colleges in Chennai