void (@NotNull Editor editor, @NotNull TextMateSnippet snippet) { String key = snippet.getKey(); int offset = editor.getCaretModel().getOffset(); int newOffset = Math.max(offset - key.length(), 0); editor.getDocument().deleteString(newOffset, offset); editor.getCaretModel().moveToOffset(newOffset); EditorModificationUtilEx.insertStringAtCaret(editor, snippet.getContent()); }