Search code examples
javascriptjs-beautify

how to configure js-beautify to preserve long string multi-lines alignment


I installed successfully js-beautify and I am using it from within xemacs on Debian Linux. By default, when formatting a string concatenated line, I get the following:

   var astr = "head of string" + avarstring + ...

I cannot find how to configure the auto-formatting of a string to respect the following indentations:

   var astr = "head of string" 
              + avarstring
              + ...

I do not really care about having the + sign at the end of each line or at the beginning, but I really need, for readability and maintenance activities, to have each separated substring to be on a single line.

Question:

  1. Which option should I use to configure this behavior?
  2. Where should I position the configuration JSON file to load this configuration?

Solution

  • Solution found:

    A new option was added a few month ago (but does not seem to be released in the npm package downloaded by default).

    • Option is present in the github: motzke/js-beautify

    • Option is named: wrap_before_operator

    • The most simple configuration directory location is in the npm directories (in my case): /usr/local/lib/node_modules/js-beautify/js/config/defaults.json