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:

MacroForRemovingLinenumber

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

objSel.EndOfDocument()
Dim endLine As Integer = objSel.ActivePoint.Line
objSel.StartOfDocument()

For line = 1 To endLine

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

objSel.LineDown()
objSel.StartOfLine()
Next

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

23 comments:

Unknown 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.

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.

Unknown 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

Himanshu May 20, 2021 at 11:08 PM

incredible and valuable content you shared with us thanks for that
keep it up..
No Addiction

Anonymous June 29, 2021 at 12:08 AM
This comment has been removed by the author.
Anonymous January 8, 2022 at 2:48 AM

Your very Nice blog, . It may useful for anyone. You may also about information USA Dedicated Server.

Anonymous February 16, 2022 at 3:17 AM

Amazing!! This blog is such as very interesting and very helpful information. Onlive Server solved my issue within a minute. We had big trouble before and they had always solved the problem. If you are looking to buy the best WordPress hosting go with Onlive Server they offer 24 hours support. Their slogan is faithful "Your hosting our responsibility" they always help us whenever we had a problem. Big thumbs up to Onlive Server. you can get from Best WordPress Hosting. So, what are you waiting for? Buy Now!

Italyserver February 16, 2022 at 3:23 AM

If you are looking for fastest and cheapest Best VPS Hosting you can ask us for more details and services.

Anonymous February 16, 2022 at 3:28 AM

Great blog. Quickly explained the topic with many points to clear all doubts. I can allow you to collect information for the domain Instant Domain Search. you can ask us for more points and services.

Anonymous February 16, 2022 at 3:29 AM


Thanks for your information, this is nice and helpful… Definitely going to share this article on my Facebook page, thanks for sharing this blog article. Best Cheap VPS

Anonymous February 16, 2022 at 3:54 AM

This is a very helpful blog for everyone. I am interested in your blog for reading. Apart from it more knowledge about USA Dedicated Server, then visit my link. Thank for You

Anonymous February 16, 2022 at 10:47 PM

Wonderful blog... I read your blog, it's the best and most useful information. You have done good work. If you are interested to know server hosting you can choose the best Best Dedicated Server it offers an amazing hosting solution to users. Thanks.....

Anonymous May 6, 2022 at 12:29 AM

Amazing blog...Thank you for the very good and meaningful blog. It is very helpful for all blog writers. In this article, you define how to start a blog you also defined what is the right way to choose the right way for the topic. if you want to write a new blog you have a great opportunity to write a blog on the new topic of Server hosting. You Should write on South Africa VPS Hosting it offers an amazing hosting solution to users.

Anonymous June 15, 2022 at 3:15 AM

Wow, What an amazing blog post by you. I really found this too much information. It is what I was searching for. I would like to suggest you that please keep sharing such type of info. Are know What is Norway VPS Hosting? If not,Norway VPS Server is the best for your online business. For more info contact me and I Will help you. thanks a lot...

Akash Yadav July 27, 2022 at 5:06 AM

Thanks for posting,very nice informative blog,good content provide here. Todaylivenews247 is a professional and instant news reporting facility that provides real-time community information. Our users can share their thoughts, opinions, and experiences on the latest happenings right in the middle of it all!

Anonymous July 28, 2022 at 5:27 AM
This comment has been removed by the author.
Anonymous July 28, 2022 at 5:29 AM

I loved your blog post! You did an excellent job of presenting the facts and research on the issue, and I think that the article serves as a great springboard for further discussion. India VPS Server is the best option for hosting online business.