question:
If you copied a code example using two space indentation and want to convert it to four space indentation, what is the quickest and simplest solution?
Matt Stauffer, Twitter
I wrote an article a few years ago on how to do this in Sublime Text. I don't think there is much difference in how to operate in VS Code.
But here is another way: use CodePen.
Suppose you found some code elsewhere, just copy and paste it here:
If you already have a CodePen account, you may have set it up, so the default settings are what you like. But if not, please adjust it in the Pen settings area:
You can do it manually here:
If you save the Pen and enable the "Format on Save" option, you may not need to use that option at all, as it will be formatted automatically.
It will quickly switch to the new 4 space indentation setting:
CodePen uses Prettier in the background to do this. So, this can be done anywhere you can access the Prettier working version, but it may be easier on CodePen, as there is no need to edit the configuration file or adjust any settings. Prettier also has its own playground, which may be as easy as CodePen, except that you may have set your preferences on CodePen, saving a step.
The above is the detailed content of One Way to Convert Code Indentation. For more information, please follow other related articles on the PHP Chinese website!