How to count how many characters are in a selection?

Asked

Viewed 42 times

0

Is there any way, trick or extension to Visual Studio 2015 that tell me how many characters are in the selection I made, including spaces or null characters?

Observing: I want to count the selection of Visual Studio itself, from its own text editor, I’m not doing a project that counts selections.

  • Its application is Web Form, Windows Forms or ...???

  • That makes no difference, I want the selection of Visual Studio itself, in its own code editor.

  • So please put this information, that the text is the code of your application!

  • I’ll edit the question.

  • @Cypherpotato The answer solved what was in doubt? Do you need something else to be improved? Do you think it is possible to accept it now?

1 answer

2


I believe that an answer in the OS does more or less what you want. It would be something like this:

using System;
using EnvDTE;
using EnvDTE80; //não sei se precisa de todos eles
using EnvDTE90;
using EnvDTE90a;
using EnvDTE100;
using System.Diagnostics;

public class CountNonWhiteSpaceCharacters {
    void Count() {
        //coloca onde quiser, pode ser no status, abrir outro tipo de controle, etc.
        MsgBox("Count " + DTE.ActiveDocument.Selection().Text.Length.ToString());
    }
}

I put in the Github for future reference.

Need to register to this extension. There documentation which can help if you’ve never created an extension for Visual Studio.

  • seriously that I will have to compile an extension to just show me how many fine letters there are in a selection? it does not come with this "factory"?

  • No: https://visualstudio.uservoice.com/forums/121579-visual-studio-2015/suggestions/7141458-show-count-of-selected-characters

  • 1

    The VS has some things kind of silly. I even stop to put italics comment needs extension. It’s a powerful tool, but there’s a lot of "I’m a developer of VS don’t use it, so don’t need to".

  • Sorry for the ignorance, @bigown, but I couldn’t find anything about the link you sent me: http://prntscr.com/cutdag

  • Ah, now that I saw it was a Feedback... "we are not including it in our plans at present".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.