int (final Editor editor, final int tailOffset) { Document document = editor.getDocument(); int textLength = document.getTextLength(); CharSequence chars = document.getCharsSequence(); int afterWhitespace = CharArrayUtil.shiftForward(chars, tailOffset, " \n\t"); if (afterWhitespace < textLength && chars.charAt(afterWhitespace) == ':') { return moveCaret(editor, tailOffset, afterWhitespace - tailOffset + 1); } document.insertString(tailOffset, " : "); return moveCaret(editor, tailOffset, 3); }