Retrieve tab size from CodeStyleSettings Kay Stenschke Created May 20, 2013 14:01 I need to know how to retrieve the conifgured tab size (of the file type of the currently edited document) from the CodeStyleSettings.thanks for any help :-)
Hi Kay,
CommonCodeStyleSettings.getIndentOptions().TAB_SIZE
Denis
Hi Denis,
thanks a lot for your answer! :)
here my solution with a fallback to the general tabsize of the project, in case someone else needs it:
// Get tab size
Integer tabSize = 0;
Project project = editor.getProject();
PsiFile psifile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
CommonCodeStyleSettings commonCodeStyleSettings = new CommonCodeStyleSettings(psifile.getLanguage());
CommonCodeStyleSettings.IndentOptions indentOptions = commonCodeStyleSettings.getIndentOptions();
if(indentOptions != null) {
tabSize = commonCodeStyleSettings.getIndentOptions().TAB_SIZE;
}
if(tabSize == 0) {
tabSize= editor.getSettings().getTabSize(editor.getProject());
}
Greetings, Kay