Sublime Forum

Auto-add comments on new line in stylus and css context

#1

Hello.

I am trying to achieve this.

This is done using DocBlockr for non-css context, but I can’t figure out how it’s done on CSS context.

That said, is there a way to it?

Perhaps a way to configure DocBlockr to do it or even a suggestion for an alternative plugin?

Thank you.

0 Likes

#2

This works out of the box using DocBlocker, with the exception of the C++ style Line comment (//) comment which isn’t considered a valid comment in CSS as far as I know (only the /* */ style and in certain circumstances <!-- -->).

This is using Sublime 3131 (it works the same in 3126 though) with only PackageControl and DocBlockr installed, with no custom configuration of DocBlockr at all:

0 Likes

#3

I personally prefere Doxygen.

0 Likes

#4

Thing is, this does not work on “stylus” context.

Also, when for stylus using // kind of comments is acceptable.

Thank you.

0 Likes

#5

Whoops, my bad; I missed that.

Assuming you’re using this stylus package, part of the reason why it doesn’t work for you is because DocBlockr has key bindings assigned to Enter that trigger this, but the Stylus plugin has a binding for Enter as well, which is taking precedence and stopping DocBlockr from seeing the key.

If you use the Enter key on your numeric keypad (assuming your keyboard has one), you should see it working for you for /** */ style comments, because DocBlockr also puts the same binding on that key, but Stylus does not.

To get around this you can copy all of the bindings for the Enter key from the DocBlockr key bindings into your User bindings, which always take precedence. The Stylus key binding has a context that makes it specifically apply to stylus files, so you would also need to modify your copied bindings with the same context.

This won’t get you support for // style comments, though. I didn’t delve too deeply into the code for DocBlockr but I suspect that it knows not to trigger for CSS because it’s not a valid comment there, so some more work may need to be done there to get it doing what you want.

On the other hand if you just need it to continue the comment for you when you’re on a single line comment and you press enter, you could create your own custom binding for that.

1 Like