How do I get semicolon on end of line on Reformat Code?

Whenever I Reformat Code for javascript files my semicolon at the end of functions (yes, I know they are unnecessary) end up on a new line, instead of at the end of the function.

How can I change this?

Also, is there a way to get code to be formated automatically? Right now I have to ctrl+alt+L manually when I want it to reformat to my standards.

4 comments
Comment actions Permalink

Hi Johan,

Whenever I Reformat Code for javascript files my semicolon at the end of functions (yes, I know they are unnecessary) end up on a new line, instead of at the end of the function.

How can I change this?

No idea -- there is no settings (at least I cannot find any) to have semicolon on new line in first place. I would suggest switching back to default Code Style and see if it helps. If it does -- try creating new svheme and configure it to your needs. If there will be no difference -- please provide your code fragment as well as Code Style settings (you can export it as a file).

Also, is there a way to get code to be formated automatically? Right now I have to ctrl+alt+L manually when I want it to reformat to my standards.

No. During editing -- only manually. I think there is an option to reformat before submitting to VCS, but that is a bit different to what you are asking.

0
Comment actions Permalink

Heres a code snippet.

var http = require("http");
var url = require("url");

function start() {

    function onRequest(request, response) {
        var pathname = url.parse(request.url).pathname;
        console.log("Request for " + pathname + " received.");
        response.writeHead(200, { "Content-Type":"text/plain"});
        response.write("Hello world!");
        response.end();
    }

    ;

    http.createServer(onRequest).listen("1337");
    console.log("Server started.");

}
;

exports.start = start;


As you can see, the semicolons when refactored end up on new lines. This is with the default setting.

Attached my settings.


Attachment(s):
settings.jar
0
Comment actions Permalink

Now I see what semicolons you were talking about. I have the same result.

Please file a new ticket with this code example to the Issue Tracker: http://youtrack.jetbrains.net/issues/WI


BTW -- attached file has no code style settings (and I do not think that they will be required here -- just letting you know).

0
Comment actions Permalink

Alright, thank you Andriy.

0

Please sign in to leave a comment.