int (int offset) { Document document = myEditor.getDocument(); if (offset == 0) { return 0; } int lineNumber = myEditor.offsetToLogicalPosition(offset).line; CharSequence text = document.getCharsSequence(); int newOffset = offset - 1; int minOffset = lineNumber > 0 ? document.getLineEndOffset(lineNumber - 1) : 0; boolean camel = myEditor.getSettings().isCamelWords(); for (; newOffset > minOffset; newOffset--) { if (EditorActionUtil.isWordStart(text, newOffset, camel)) { break; } } return newOffset; }