---
title: "caret.set: Set Caret — Doc kit command — Kition"
description: "Puts the caret at a position (a document position, as file.selection answers) or at a point on a page, optionally extending the selection. With `unit` it selects the word, line, paragraph (with its mark) or paragraph's text (without it) at `pos`; with `extend` too, the selection grows by that unit from the range `start`..`end` (else the anchor), which stays selected."
canonical: "https://developer.kition.ai/docs/kits/doc/commands/caret.set"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/doc/commands/caret.set](https://developer.kition.ai/docs/kits/doc/commands/caret.set)

# caret.set

**Set Caret.** Puts the caret at a position (a document position, as file.selection answers) or at a point on a page, optionally extending the selection. With `unit` it selects the word, line, paragraph (with its mark) or paragraph's text (without it) at `pos`; with `extend` too, the selection grows by that unit from the range `start`..`end` (else the anchor), which stays selected.

- Kit: Doc 0.1.0 (.docx); reference: [Doc kit commands](https://developer.kition.ai/docs/kits/doc.md)
- Changes the document: no

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `end` | `object` | no | where the range the selection grows from ends (with `unit` and `extend`) |
| `extend` | `boolean` | no | in one of several forms of the parameters |
| `page` | `integer` | no | in one of several forms of the parameters |
| `pos` | `object` | no | a position as file.selection answers |
| `start` | `object` | no | where the range the selection grows from starts (with `unit` and `extend`) |
| `story` | `string \| object` | no | read by the command beside its listed parameters |
| `unit` | `"word" \| "line" \| "paragraph" \| "paragraphText"` | no | in one of several forms of the parameters |
| `x` | `number` | no | points; in one of several forms of the parameters |
| `y` | `number` | no | points; in one of several forms of the parameters |

## Call through doc_run

```text
doc_run {
  "path": "<file>.docx",
  "steps": [{ "command": "caret.set" }]
}
```

The required parameters, with placeholders for their types: not a tested example. Optional: `end`, `extend`, `page`, `pos`, `start`, `story`, `unit`, `x`, `y`. doc_run answers the step’s result in `completed[i].result`.

## Result

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `anchor` | `object` | no |  |
| `focus` | `object` | no |  |

```json
{
  "additionalProperties": true,
  "properties": {
    "anchor": {
      "additionalProperties": true,
      "properties": {
        "off": {
          "type": "number"
        },
        "path": {
          "items": {
            "type": "number"
          },
          "type": "array"
        },
        "story": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "focus": {
      "additionalProperties": true,
      "properties": {
        "off": {
          "type": "number"
        },
        "path": {
          "items": {
            "type": "number"
          },
          "type": "array"
        },
        "story": {
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "type": "object"
}
```

## Parameter schema

```json
{
  "additionalProperties": false,
  "properties": {
    "end": {
      "additionalProperties": true,
      "description": "where the range the selection grows from ends (with `unit` and `extend`)",
      "properties": {
        "off": {
          "description": "character offset in the paragraph",
          "type": "integer"
        },
        "path": {
          "description": "paragraph path counted from 0",
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        "story": {
          "description": "\"body\", or {\"part\": n} for a header, footer, note, comment or text box story",
          "oneOf": [
            {
              "enum": [
                "body"
              ],
              "type": "string"
            },
            {
              "additionalProperties": false,
              "properties": {
                "part": {
                  "description": "header, footer, footnote, endnote, comment or text box story number",
                  "type": "integer"
                }
              },
              "type": "object"
            }
          ]
        }
      },
      "type": "object"
    },
    "extend": {
      "description": "in one of several forms of the parameters",
      "type": "boolean"
    },
    "page": {
      "description": "in one of several forms of the parameters",
      "type": "integer"
    },
    "pos": {
      "additionalProperties": true,
      "description": "a position as file.selection answers",
      "properties": {
        "off": {
          "description": "character offset in the paragraph",
          "type": "integer"
        },
        "path": {
          "description": "paragraph path counted from 0",
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        "story": {
          "description": "\"body\", or {\"part\": n} for a header, footer, note, comment or text box story",
          "oneOf": [
            {
              "enum": [
                "body"
              ],
              "type": "string"
            },
            {
              "additionalProperties": false,
              "properties": {
                "part": {
                  "description": "header, footer, footnote, endnote, comment or text box story number",
                  "type": "integer"
                }
              },
              "type": "object"
            }
          ]
        }
      },
      "type": "object"
    },
    "start": {
      "additionalProperties": true,
      "description": "where the range the selection grows from starts (with `unit` and `extend`)",
      "properties": {
        "off": {
          "description": "character offset in the paragraph",
          "type": "integer"
        },
        "path": {
          "description": "paragraph path counted from 0",
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        "story": {
          "description": "\"body\", or {\"part\": n} for a header, footer, note, comment or text box story",
          "oneOf": [
            {
              "enum": [
                "body"
              ],
              "type": "string"
            },
            {
              "additionalProperties": false,
              "properties": {
                "part": {
                  "description": "header, footer, footnote, endnote, comment or text box story number",
                  "type": "integer"
                }
              },
              "type": "object"
            }
          ]
        }
      },
      "type": "object"
    },
    "story": {
      "description": "read by the command beside its listed parameters",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "additionalProperties": true,
          "type": "object"
        }
      ]
    },
    "unit": {
      "description": "in one of several forms of the parameters",
      "enum": [
        "word",
        "line",
        "paragraph",
        "paragraphText"
      ],
      "type": "string"
    },
    "x": {
      "description": "points; in one of several forms of the parameters",
      "type": "number"
    },
    "y": {
      "description": "points; in one of several forms of the parameters",
      "type": "number"
    }
  },
  "type": "object"
}
```

Generated from the command list of @kition/doc-darwin-arm64@0.1.0 and the kit itself (doc_commands through @kition/cli@0.1.1, built from KitionAI/kition-doc@41e14a8).
