Is there a way to hide comments? I have to heavily comment my code. Iād love to be able to turn comments on and off so that it would show or hide comments. Is this possible?
How to hide comments
It is possible, but not out of the box. You could write a plugin that finds all comments, and then fold all of those regions with one command, and then with another command unfolds all of those comments.
Hm⦠I canāt be the only human being to want this functionality. I guess I got to start researching how to write a Sublime Text 2 plugin.
Basically, it is:
view.fold(view.find_by_selector('comment'))
Now if you want a nice result, you must probably tweak a little bit the regions returned by find_by_selector (join adjacent regions, add/remove line ending, ā¦)
[quote=ābizooā]Basically, it is:
view.fold(view.find_by_selector('comment'))
Now if you want a nice result, you must probably tweak a little bit the regions returned by find_by_selector (join adjacent regions, add/remove line ending, ā¦)[/quote]
Do you happen to have that in a nice package already?
[quote=ājbrooksukā]
[quote=ābizooā]Basically, it is:
view.fold(view.find_by_selector('comment'))
Now if you want a nice result, you must probably tweak a little bit the regions returned by find_by_selector (join adjacent regions, add/remove line ending, ā¦)[/quote]
Do you happen to have that in a nice package already? [/quote]
Yeah, I donāt know Python at allā¦
If I get some time in the next couple of days (and someone else hasnāt beaten me to the punch), I may take a swing at this; we shall see.
If you end up giving it a try and have issues, just post your questions here, and I am sure you will get help; there are a lot of people here with python/plugin experience, and most are pretty helpful.
[quote=āwesllyā]actually this is pretty easy, this plugin should solve the problem
cl.ly/312l47310A181h3f1116[/quote]
Nice!
[quote=āfacelessuserā]
[quote=āwesllyā]actually this is pretty easy, this plugin should solve the problem
cl.ly/312l47310A181h3f1116[/quote]
Nice![/quote]
Wow! Super nice community! Thank you!
Now⦠Iām kind of a n00b to this Sublime Text 2 thing. How do I install & use this? Iām used to installing things with the package explorer.
Go to Preferences->Browse Pakages and drop the FoldComments folder in there.
He added two commands in the command palette: āfold commentsā and āunfold commentsā. So just press Ctrl+Shift+p and start typing the command, you should see it pop up; select it and go.
Hi people,
Iāve extended upon the work of the other plugins in this thread and created my own plugin, with additional features such as concatenating adjacent single/block comments, and making sure the fold-indicator isnāt munged together with adjacent code.
It is available here: https://github.com/oskarols/foldcomments
Itās also added to the Package Manager as āFold Commentsā.
the first one linked is my favorite, however I need it to have an end of line character after the last folded block in succession.
How would I accomplish this? Current code is:
class FoldCommentsCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.fold(self.view.find_by_selector('comment'))
class UnfoldCommentsCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.find_by_selector('comment'):
self.view.unfold(region)
But I want to add in an end of line and then remove it after⦠or is there a way to change the way folding works?
Hi all,
First post, so be gentle if I offend some netiquette you all have going
(I did a cursory google search on this, but perhaps I donāt know the right vernacular.)
I have a followup question.
Can someone tell me (or point me to documentation) that explains what happens when one adds a plugin (like the download above) or writes their own, and then a newer āofficial releaseā includes the same functionality?
Do you just need to attend to the change-log to see what is new, and is there a recommended method of documenting your āadd-onā (contributed and home-grown) plugins (like a personal change-log to your copy)? Is there a coding standard (like doxygen) that can āharvestā this data dynamically?
Regards,
Brad
And if youād like to replace the distracting yellow icon that replaces folded text, hereās a clean grey icon with transparency.
Save this image:
Rename it fold.png, and move it to Packages > Theme - Default
.
Donāt forget to backup the old yellow fold icon by saving the original fold.png under an alternative name.