Sublime Forum

Un-Comment works Inconsistently

#1

Not sure where to post this, but the support link directed me to the forums… so here goes

I’ve been using Sublime Text 2 for a few weeks, after purchasing it. I like a great many things about it… but I’m struggling with the comment/un-comment feature. I’ve poured through the forums and haven’t found anyone else with the same exact problem… though the second issue I’ll discuss (related) is pretty common. To be clear, my keybindings are NOT the problem… the shortcut works when I trigger it… but it’s behaving odd.

Some obligatory lUser details:
Mac OS X version 10.7.3 (Lion, fully up to date)
8GB RAM
Sublime Text 2 beta, build: 2181

*** I have not tested this in Sublime Text 1 ** *

First problem:

Example: I comment a line (let’s say a style, in a .css file) and want to un-comment it later

a {color:red; text-decoration:none}

Command / does this:

/*a {color:red; text-decoration:none}*/

Then later on I decide to un-comment it… because I’m done debugging this really tough link style :wink:

Command / sometimes removes the comment, but a lot of the time it does this instead:

/*/*a {color:red; text-decoration:none}*/*/

Now you’re probably saying “cool, we just commented something twice!”, and I might be inclined to agree with you, if I enjoyed manually un-commenting things… but I have to be honest, I like comment/un-comment to “just work” :wink:
(let the flames begin, for using a phrase like “just work”)

I believe this has something to do with placing your cursor in the right spot before you envoke the un-comment command. I don’t know how this is calculate, but un-commenting only works “some of the time”. Quite often if I go back and un-comment something from earlier in the day, I’ll end up with double-comments.

OK… so that’s my big gripe.

My other issue is related to comments in embedded code (ie, javascript inside an html file, or css inside an html file). I can’t seem to get a grip on how it decides which language to use when commenting. Sometimes it will use html comments, sometimes not…

OK… thanks for hearing me out. Hopefully someone else has experienced this problem with commenting/un-commenting (the first problem I described)

0 Likes

#2

I’ve seen similar behavior which may be related to the same issue. I’m using the Windows7-64bit version.

I see this happen typically in Javascript files, where I have a large block comment at the beginning and end of the file. I have other multiline block comments scattered around the file, I’m not really sure how much detail to include here. In general, the file might look like this:

[code]/*************************
Some comments describing the file
*************************/

code code code

/*************************
some comments describing the section that starts here
/
code code code
/

comments indicating that this is the end of the previous section
*************************/[/code]

Occasionally when I highlight a multiline chunk and use the hotkey to comment it (I don’t think I’ve noticed the behavior when I uncomment), instead of commenting out the highlighted code it removes the start of the first comment, and the end of the last comment, e.g.:

************************ <- characters removed from beginning Some comments describing the file *************************/ ... /************************* comments indicating that this is the end of the previous section ************************ <- characters removed from end

So the first 2 characters of the comment opening the file were removed, and the last 2 characters of the last block comment were removed. Obviously this results in syntax errors if I don’t catch it.

Otherwise, Sublime is a great piece of software. The syntax highlighting alone is amazing (I love the nested SQL string highlighting, even though it doesn’t survive concatenation).

0 Likes