Sublime Forum

wrap_lines: formatting improvement (PHP)

#1
/**
 * Returns the owner object for the given object, or an empty owner object (with the owned object set to the given object) if an owner has not been set for the given object.
 */

I would love for this to result in

/**
 * Returns the owner object for the given object, or an empty owner object (with the owned object
 * set to the given object) if an owner has not been set for the given object.
 */

when wrapped, but instead it results in

/**
 * Returns the owner object for the given object, or an empty owner object (with the owned object
 *     set to the given object) if an owner has not been set for the given object.
 /*

The 4 spaces indenting that second line are not necessary for function descriptions - they are only useful when describing function parameters (imo, and this is how I see it being used 99% of the time in PHP).

0 Likes

#2

My bad. It does not even result in that. I had incorrectly assumed that I had disabled all my formatting packages, but apparently I still had one enabled. If only sublime could do this :).

0 Likes

#3

This might be something you already know (since you mentioned formatting plugins) but DocBlockr enhances the word wrap functionality in comments to do this.

I think by default it does an indent like you note above, but you can configure it to not do that; I use it for this very purpose and mine is configured for no such indent.

0 Likes

#4

Uhuh that is exactly the package that I use, it’s a great one. I think before I had it enabled with another package, which resulted in that function descriptions were not indented, while params of which the doc was on multiple lines would be indented. E.g. you’d get

/**
 * Finds the assignments of the user with the given ID and stores them in the given view's
 * properties.
 *
 * @param int $user_id - Finds the assignments of the user with the given ID and stores them in
 *     the given view's properties.
 * @param View $view
 */

instead of

/**
 * Finds the assignments of the user with the given ID and stores them in the given view's
 *     properties.
 *
 * @param int $user_id - Finds the assignments of the user with the given ID and stores them in
 *     the given view's properties.
 * @param View $view
 */

Any idea if this is something that can be done through the settings? Because I can’t seem to find the setting for it.

0 Likes

#5

To be sure, which plugin handle the command, you can enable logs with

    `sublime.log_commands(True)`

Once done, the best is probably to ask to the plugin’s maintainer (or here if none but improbable)

I’m not familiar with DocBlockr, but I maintain DoxyDoxygen (which also support Php). If you want to try, to configure it according yours needs, you can set

    "indentation_max": 4, // to indent only 4 spaces
    "preferred_tabs_sizes": [ 0 ], // to disable column alignment
0 Likes

#6

In DocBlockr, the indent of the next lines in a paragraph is controlled by the jsdocs_indentation_spaces_same_para setting. Setting it to 1 (which I think is the default) will result in your first example; to get the second one you would need to set it to 5.

"jsdocs_indentation_spaces_same_para": 5,
0 Likes