admin管理员组

文章数量:1391805

My javascript code is formatted like this and I'm not fortable with this :

function(
    req,
    req.session,
    amount,
    offerCode,
    userChoice,
    referenceNo,
    transactionId,
    function (err, res) {
        ...
}

I prefer to change it like this :

function( req, req.session, amount, offerCode, userChoice, eferenceNo, transactionId, function (err, res) {
    ...
}

Is there any code-formatter to do this automatically on a huge bunch of code.

My javascript code is formatted like this and I'm not fortable with this :

function(
    req,
    req.session,
    amount,
    offerCode,
    userChoice,
    referenceNo,
    transactionId,
    function (err, res) {
        ...
}

I prefer to change it like this :

function( req, req.session, amount, offerCode, userChoice, eferenceNo, transactionId, function (err, res) {
    ...
}

Is there any code-formatter to do this automatically on a huge bunch of code.

Share Improve this question edited Mar 25, 2020 at 11:08 Bahman Parsa Manesh asked Oct 14, 2019 at 8:28 Bahman Parsa ManeshBahman Parsa Manesh 2,3683 gold badges18 silver badges36 bronze badges 7
  • Prettier - Code formatter - Visual Studio Marketplace? – Praveen Kumar Purushothaman Commented Oct 14, 2019 at 8:29
  • Prettier exactly change one-line parameters to one parameter per line. Is there any setting to change this? – Bahman Parsa Manesh Commented Oct 14, 2019 at 8:36
  • 1 You can use "printWidth": whateverCharacterLengthYouWant in your .prettierrc file. After the given character length(plus some other conditions) it will e on next line.By default it is set to 80 – Debajit Majumder Commented Oct 14, 2019 at 8:49
  • 1 You can add .prettierrc at the root of your project code and you should mit that file so that everyone working on that project follow the same code styling/formatting. .prettierrc is a simple JSON file. – Debajit Majumder Commented Oct 14, 2019 at 9:31
  • 1 Happy to help you. Seems like @PraveenKumarPurushothaman just answered the same what I have mentioned here in ment. You can accept his answer and upvote my ments. – Debajit Majumder Commented Oct 14, 2019 at 10:13
 |  Show 2 more ments

1 Answer 1

Reset to default 8

The best thing to use is Prettier - Code formatter in this case. Use a file called .prettierrc in your root of the folder that you put into VS Code and add the following inside it:

{
  "printWidth": 8000
}

The default is 80 in this case.

本文标签: javascriptHow to format all parameters of a function in one line in Visual Studio CodeStack Overflow