Sublime Forum

Changing Block Comment Format

#1

Hi,

I use sublime to work with Perl predominantly and write my comments in this format (some spaces added to make the * appear)

#**************************************** #
#* Comments written here, of * #
#* varying length. * #
#****************************************#

These comments are indented alongside the code, with all the right hand hash symbols in the 80th column. Is there a way to set up a keyboard shortcut in sublime 3 so that a block of text can be automatically formatted into this style?

Thanks,
David

0 Likes

#2

Meaning you want to set up a keyboard shortcut that will automatically wrap any comments longer than 80 characters to the next line ?

0 Likes

#3

That, and also add #* to the start of each line, *# to the end, and put a solid line #**************# at the top and bottom. And if possible, pad the lines with spaces so that the *# is on the 80th character.

0 Likes

#4

Hi David,

DoxyDoxygen supports this old “comment style”.
If you still have your problem, you can try the following settings

"preferred_comments_styles": [
   [
       [ "#", "*", "#" ],
       [ "#* ", "*#" ],
       [ "#", "*", "#" ],
   ],
   ...
],

Using your example, when you press +

#****************************************#
#* Comments written here, of *#
#* varying length. *#
#****************************************#

the result will be

#****************************************************************************#
#* Comments written here, of varying length.                                *#
#****************************************************************************#

Regards,

0 Likes