void () { removeHighlighters(); final MarkupModel model = DocumentMarkupModel.forDocument(myDocument, myProject, true); final String text = myDocument.getText(); int ind = -1; while ((ind = text.indexOf(CARET, ind + 1)) >= 0) { final RangeHighlighter highlighter = model.addRangeHighlighter(ind, ind + CARET.length(), HighlighterLayer.ADDITIONAL_SYNTAX, CARET_ATTRIBUTES, HighlighterTargetArea.EXACT_RANGE); highlighter.setGutterIconRenderer(ICON_RENDERER); highlighter.putUserData(KEY, VALUE); } }