SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Did you know? => Topic started by: Dennis on July 19, 2023, 12:54:17 PM

Title: Cut-line, Unsurround, Undo, paste, and surround
Post by: Dennis on July 19, 2023, 12:54:17 PM
This is a pattern I find myself using frequently when I need to duplicate the logic found in an "if" or other block statement. 

Suppose you have some very contrived code like this:
Code: [Select]
void generateDocComment(const string &author,
                        const string &since,
                        const string &brief_description,
                        const vector<string> &details,
                        const bool just_the_essentials /*= false*/)
{
    cout << "/**" << endl;
    cout << " * @brief" << endl;
    cout << " * " << brief_description << endl;
    if (just_the_essentials && author != "") {
        cout << " *" << endl;
        cout << " * @author " << author << endl;
    }
    cout << " *" << endl;
    cout << " * @details" << endl;
    for (const auto &line : details) {
       cout << " * " << line << endl;
    }
    cout << " *" << endl;
    cout << " * @since " << since << endl;
    cout << " */" << endl;
}

And you realize that the "since" information shouldn't be there if it was blank or if they wanted just the essentials.

You can do this:

It sounds more complicated than it is, but once you grow accustomed to it, it can be a time-saver.  In newer releases of SlickEdit, the first four steps can be compressed down to one step by using copy_to_clipboard (Ctrl+C) on the first line of the "if" statement and then selecting to copy the surrounding statement.