Sublime Forum

Tweaking bulk commenting

#1

Ctrl+/ on Windows makes whatever you have selected a comment, e.g.:

test
turns into
// test

I’d like to have

test
turn into
//test

without the space between the comment and the thing being commented out. Is this possible to configure?

0 Likes

#2

Yes.

Edit Comments.tmPreferencesfile of the language you want tweaked (e.g. Comments (C++).tmPreferences) and go crazy :smile:

0 Likes

#3

Awesome! I’m super new, can you tell me how to track down the Comments.tmPreferences files on my computer to edit?

Edit: * I am using Sublime Text 3

0 Likes

#4
  1. Install this package
  2. ctrl+shift+p => open resource => select language you want => change.
0 Likes

#5

OK so I am getting closer, I opened Comments.tmPreferences for JavaScript and changed the TM_COMMENT_START to be:

<dict>
	<key>name</key>
	<string>TM_COMMENT_START</string>
	<key>value</key>
	<string>//</string>
</dict>

I saved my changes and then closed Subkime Text and reopened it. My commenting shortcut (Ctrl+/) still adds the extra space! I confirmed that the document type is JavaScript in the bottom right corner.

Am I missing something?

0 Likes

#6

Works for me. (see my Edit at the end)

Do you have modified the right one?
…\SublimeText\Packages\JavaScript.sublime-package

Or better, a copy of them, copied before to User folder:
…\SublimeText\Data\Packages\User\JavaScript.sublime-package


The manual way:

Copy “JavaScript.sublime-package”
from “…\SublimeText\Packages”
to “…\SublimeText\Data\Packages\User”

Add an zip extension. ( “.\SublimeText\Data\Packages\User\JavaScript.sublime-package.zip”)
Unzip.
Rename the new folder to “JavaScript.sublime-package-unpackt”

Go inside of “.\SublimeText\Data\Packages\User\JavaScript.sublime-package-unpackt”
Open “Comments.tmPreferences”, modify and save.

Zip all content inside of the folder “JavaScript.sublime-package-unpackt”
“.\SublimeText\Data\Packages\User\JavaScript.sublime-package-unpackt\JavaScript.sublime-package.zip”
Remove the zip extension.
“.\SublimeText\Data\Packages\User\JavaScript.sublime-package-unpackt\JavaScript.sublime-package”

Move the file “JavaScript.sublime-package” up to “…\SublimeText\Data\Packages\User”

You can delete the folder “\User\JavaScript.sublime-package-unpackt” and the older “\User\JavaScript.sublime-package.zip”


Edit:

now I also could not go back to "// ", even I removed all of my modifications. :unamused:

Solution: Delete the Cache folder “…\SublimeText\Data\Cache\JavaScript” (since I don’t know if that folder would have something useful in it, just move them only instead of actual deleting)


0 Likes

#7

Awesome, thank you Jim and imntz!

0 Likes