eclipse-cdt / cdt

Eclipse CDT™ C/C++ Development Tools
http://eclipse.org/cdt
Eclipse Public License 2.0
307 stars 201 forks source link

Editor whitespace as double-clickable #101

Open gregwillits opened 2 years ago

gregwillits commented 2 years ago

It would be very useful (productive) to have white space be double-clickable as a word.

This is a common capability in Mac software, so in all my other editors and even word processor do this, and I find myself auto-piloting in Eclipse, but having to do more difficult keyboarding which takes longer. (All small differences of course, but still noticable in the work flow.)

Let me explain...

If we look at the code fragment below, the text is aligned in pseudo columns. Let's say that the word Length needs to change to Size, so that delimiterLength becomes delimiterSize, and csvStringLength becomes csvStringSize. Let's also say we change elements to members, and maxLimit to stringLimit.

struct mCsvList {
    size_t          elementLimit;       // Max allowed size of the text for each element.
    size_t          maxLimit;           // Max allowed size of the joined CSV string.
    const char*     delimiter;          // Copy of delimiter.
    size_t          delimiterLength;    // Store to avoid having to calculate it repeatedly.
    char*           csvString;          // Final cleaned up CSV string.
    size_t          csvStringLength;    // Size of the final CSV string.
    char**          elements;           // The internal array of value elements.
    size_t*         elementSizes;       // The size of each array element string.
    unsigned int    count;              // The number of elements.
};

After refactoring, we get this. Now it's time to realign the comments. Many ways to do that.

struct mCsvList {
    size_t          elementLimit;       // Max allowed size of the text for each element.
    size_t          stringLimit;           // Max allowed size of the joined CSV string.
    const char*     delimiter;          // Copy of delimiter.
    size_t          delimiterSize;    // Store to avoid having to calculate it repeatedly.
    char*           csvString;          // Final cleaned up CSV string.
    size_t          csvStringSize;    // Size of the final CSV string.
    char**          members;           // The internal array of value elements.
    size_t*         memberSizes;       // The size of each array element string.
    unsigned int    count;              // The number of elements.
};

What I find the fastest (not necessarily the fewest key strokes) in my other editors is that I double click in the white space gap, and press tab as needed to realign. So, double click in the gap of stringLimit; // Max will select the entire white space between ";" and "/" just like double-clicking a word. It's a very quick right hand on the mouse double-clicking the affected gaps, and left hand whacking Tab.

I use this without even thinking about it in so many places. I suspect there's better examples, but this is what popped into my head. Oh — even when mouse navigating around reading things, I might spot a place with extra spaces, I just double-click, hit Space or Tab, and done — vs. having to drag, or use shift-command-arrow key combinations to make a wide selection.

It surprises me that it's not a universal mouse behavior like word selecting. In Microsoft-land, Word doesn't do it, but Visual Studio Code does. Notepad tries to but it differentiates tabs vs spaces (defeats the purpose). Adobe doesn't do it in InDesign copy text, but in any of the user interface fields like creating a new Stye name, it does (probably leaning on standard Apple behavior there).

I don't know if it is something that can be added to CDT alone, or if you have to lobby for support all the way up the food chain. It is a small but productive selection behavior that I would find very useful in the Eclipse editor.

Thanks for all your work.

-- greg

jonahgraham commented 2 years ago

This looks like something that the CDT editor needs to do. AFAICT the JDT (Java) editor does what you want. The CDT editor was originally created as a clone of the JDT editor, and it looks like this is an improvement that needs to be ported across.

gregwillits commented 2 years ago

Schweet :-) Thanks.