void (Editor editor, CharSequence docChars, int nextOffset) { if (nextOffset < docChars.length() && docChars.charAt(nextOffset) == ' ') { editor.getCaretModel().moveToOffset(nextOffset + 1); } else { editor.getCaretModel().moveToOffset(nextOffset); EditorModificationUtil.insertStringAtCaret(editor, " ", false, true, 1); } }