How do I get semicolon on end of line on Reformat Code?
Followed by 3 people
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.
Please sign in to leave a comment.
Hi Johan,
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).
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.
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
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).
Alright, thank you Andriy.
Is this issue added? Where can I find it? Or do you have an other solution?
Nevermind, this can be accomplished by unchecking "Place ';' on new line" in "Preferences" > "Editor" > "Code Style" > "PHP" > "Wrapping and Braces" > "Chained method calls"