Sublime Forum

Comment character at the beginning of the line

#1

Is there a way to insert the comment character at the beginning of the line
instead of at the position where the text starts when using the shortcut keys
(shift + /) to comment lines?

For instance, I have a fuzzy code like this:

AAAA BBBB CCCC DDDD

And I automatically comment lines 2 and 3, the result is:

AAAA # BBBB # CCCC DDDD

What I would like to get is:

[code]AAAA

BBBB

CCCC

DDDD
[/code]

Not a big deal but it’s something I was able to toggle in Geany editor
and I cannot find a way to configure in Sublime.

Thank you!

0 Likes

#2

This is a per-language thing that you can get by including the following in the “Comments.tmPreferences” file of that language package.

<dict> <key>name</key> <string>TM_COMMENT_DISABLE_INDENT</string> <key>value</key> <string>yes</string> </dict>

1 Like

#3

[quote=“frou”]This is a per-language thing that you can get by including the following in the “Comments.tmPreferences” file of that language package.

<dict> <key>name</key> <string>TM_COMMENT_DISABLE_INDENT</string> <key>value</key> <string>yes</string> </dict>[/quote]

How would you achieve this in ST3? I don’t feel like modifying the inside of the application.

Thanks, Ákos

0 Likes

#4

@asomorjai, sublime-package files are simply zipfiles with another extension. So,

  1. Open the required language sublime-package file in your favourite zip program
  2. extract the Comments.tmPreferences file somewhere into your User folder
  3. Edit and save the file to make the desired changes to comment behaviour

If you take a look at Comments (C++).tmPreferences you can see how and where TM_COMMENT_DISABLE_INDENT should be used.

:smile:

0 Likes