How to count how many characters are in a selection?

0

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

Note: I want to tell the selection of Visual Studio itself, from its own text editor, I am not doing a project that has selections.

    
asked by anonymous 16.10.2016 / 02:41

1 answer

2

I believe an answer in SO does more or less what you want. It would look 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());
    }
}

You need to register to this extension. There are documentation that can help if you've never created an extension for Visual Studio.

    
16.10.2016 / 03:04