void (Editor editor) { int caretOffset = editor.getCaretModel().getOffset(); Document document = editor.getDocument(); CharSequence text = document.getImmutableCharSequence(); editor.getSelectionModel().setSelection(CharArrayUtil.shiftForward(text, DocumentUtil.getLineStartOffset(caretOffset, document), " \t"), CharArrayUtil.shiftBackward(text, DocumentUtil.getLineEndOffset(caretOffset, document) - 1, " \t") + 1); }