void (Document document) { int i = document.getText().indexOf(marker); if (i==-1) return; WriteCommandAction.runWriteCommandAction(getProject(), () -> document.replaceString(i, i + marker.length(), "")); removeGarbage(document); }