Sublime Forum

Can I prevent indentation for toggle comment?

#1

Hi,

I prefer line comments to start at column 0 instead of current block indentation, if they are used to comment out some unused code.
This is the main use case for me to use the Toggle Comment feature.

(I do indent informational comments, but hardly ever need the Toggle Comment feature there.)

So for example


function foo() {
    var a = 1,
//         b = 2,
         c = 3;

//    alert("Called foo");
    ...]
}

function bar() {
    // I do indent informational comments though
}

Currently I get this instead:

function foo() {
    var a = 1,
         // b = 2,
         c = 3;

    // alert("Called foo");
    ...]
}

Is this configurable?

Martin

0 Likes

Python/C++: Indenting Comments
#2

I think this can only be done per-language and that’s by editing the “Comments.tmPreferences” file of that language package.

Just as TM_COMMENT_START is defined to be “//”, you can define TM_COMMENT_DISABLE_INDENT to be “yes”.

0 Likes

#3

Thanks for your answer and sorry for the late response.

Does that mean that I have to unzip the language file, then edit the included XML file, zip it again, and replace the original file?

0 Likes

#4

An alternative, if you’re comfortable with writing plugins or working with Python: Copy comment.py from the Default package into your User directory, change it to not indent, give the command a different name (like ToggleComment2) and override the keybinding to use your new plugin.

0 Likes