Wanted: Solidity formatter for Visual Studio Code

@dennison wants a Solidity formatter for Visual Studio Code.

As far as I can tell, there isn’t one yet.

We have Juan Blano’s essential Solidity extension, but this doesn’t do formatting currently. https://github.com/juanfranblanco/vscode-solidity/issues/18

Solium can do code formatting (I haven’t tried):


The other option could be to create a formatter extension:

Any suggestions on how to automagically format Solidity?


QW4K on reddit: There is a prettier for solidity plugin https://github.com/prettier-solidity/prettier-plugin-solidity

1 Like

@dennison I have asked the community on the forum, Reddit, Telegram groups, Discord. At this stage it looks like the prettier extension is the closest to a Visual Studio Code formatter extension.

The dream for “Shift+Alt+F” to format a document, or “Ctrl+K Ctrl+F” to format a selection will have to wait until we (or someone else in the community) creates a Solidity formatter extension.

1 Like

It’s actually something that I want for a long time. Same as when you star typing /** and press enter, it generates a basic comment format, like in JS. About this second one, I’ve actually discussed that with juan, but I’ve never done it. I haven’t had time to try any of this two, but it is defenetly two things that I want to have and I will try to find some time to build them.

BTW, thaks for the prettier, I didn’t knew it. So many good stuff out there.

1 Like

Worth reading https://medium.com/coinmonks/introduction-to-solidity-linting-and-formatting-e838c074791a

1 Like

Hi @juanfranblanco,

Are there any plans to include or create a formatter extension to format Solidity for VS Code?

1 Like

I was expecting one of the linters to provide this, included fixing the spaces. Obviously this spaces has dried up a bit over the last year, so it might end up something that will have to come up directly from the extension. Simple formatting won’t be hard to do, if we set a number of spaces / tabs per section, and leave the AST for other things.

Regarding the autocomment, I have seen there, solparse can help with that, or maybe the new functionality to output just the AST of solidity (which i think is finished now)

1 Like

I think the best option will be to officially integrate the solidity plugin for prettier https://github.com/prettier-solidity.

1 Like