void (final @NotNull String text) { Runnable runnable = () -> ApplicationManager.getApplication().runWriteAction(() -> { final Document document = myEditor.getDocument(); document.replaceString(0, document.getTextLength(), StringUtil.convertLineSeparators(text)); }); CommandProcessor.getInstance().executeCommand(myProject, runnable, "", this); }