void () { @NonNls String fileText = """ <html> <head><title>Simple jsp page</title></head> <body> <p>Place your co</p> <p>ntent here</p> </body> </html>"""; XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("test.html", fileText); final XmlTag bodyTag = file.getDocument().getRootTag().getSubTags()[1]; CodeStyleManager.getInstance(getProject()).reformatRange( bodyTag, bodyTag.getTextRange().getStartOffset(), bodyTag.getTextRange().getEndOffset()); }