emeditor

Is there a shortcut to comment and uncomment in emeditor?


In vscode , ctrl+/ can comment , and can also uncomment , does emeditor support this? enter image description here


Solution

  • By default, Ctrl+K, C to comment, and Ctrl+K, U to uncomment. You can always change the keyboard shortcuts.

    If you need to toggle Comment/Uncomment, you will need to write a macro like this:

    s = document.selection.Text;
    if( s.length == 0 ) {
        s = document.GetLine( document.selection.GetActivePointY( eePosLogical ) );
    }
    if( s.length >= 2 && s.substr( 0, 2 ) ==  "//" ) {
        editor.ExecuteCommandByID(4372);  // Uncomment
    }
    else {
        editor.ExecuteCommandByID(4371);  // Comment
    }
    

    This macro assumes the first two characters of a comment line is //.