code: function findPosSubword(doc, start, dir) {
      if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1));
      var line = doc.getLine(start.line);
      if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0));
      var state = "start", type;
      for (var pos = start.ch, e = dir < 0 ? 0 : line.length, i = 0; pos != e; pos += dir, i++) {
        var next = line.charAt(dir < 0 ? pos - 1 : pos);
        var cat = next != "_" && CodeMirror.isWordChar(next) ? "w" : "o";
        if (cat == "w" && next.toUpperCase() == next) cat = "W";
        if (state == "start") {
          if (cat != "o") { state = "in"; type = cat; }
        } else if (state == "in") {
          if (type != cat) {
            if (type == "w" && cat == "W" && dir < 0) pos--;
            if (type == "W" && cat == "w" && dir > 0) { type = "w"; continue; }
            break;
          }
        }
      }
      return Pos(start.line, pos);
    }
docs: This is not exactly Sublime's algorithm. I couldn't make heads or tails of that.