Skip to content

Ignoring multi line comments #135

@Nishant-Pall

Description

@Nishant-Pall

Is there a way to make prettier ignore commented lines inside the file that's supposed to be formatted?
I noticed this when I commented a whole function, and once I execute :Prettier, Prettier stripped out the indentation and basically pushed all of the lines above each other with no spaces to the left. Something like this.

Before calling :Prettier

//const reducer = (state = initialState, action) => {
    //switch (action.type) {
        //case BUY_CAKE:
            //return {
                //...state,
                //numOfCakes: state.numOfCakes - 1,
            //};
        //case BUY_ICECREAM:
            //return {
                //...state,
                //numOfIceCreams: state.numOfIceCreams - 1,
            //};
        //default:
            //return state;
    //}
//};

and after calling :Prettier

//const reducer = (state = initialState, action) => {
//switch (action.type) {
//case BUY_CAKE:
//return {
//...state,
//numOfCakes: state.numOfCakes - 1,
//};
//case BUY_ICECREAM:
//return {
//...state,
//numOfIceCreams: state.numOfIceCreams - 1,
//};
//default:
//return state;
//}
//};

It does work in vscode, but apparently doesnt in neovim

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions