Skip to content

Norg Text Objects

github-actions[bot] edited this page Jul 16, 2024 · 6 revisions

core.text-objects

Navigation, Selection, and Swapping

Overview

  • Easily move items up and down in the document
  • Provides text objects for headings, tags, and lists

Usage

Users can create keybinds for some or all of the different events this module exposes. Those are:

  • core.text-objects.item_up - Moves the current "item" up
  • core.text-objects.item_down - same but down
  • core.text-objects.textobject.heading.outer
  • core.text-objects.textobject.heading.inner
  • core.text-objects.textobject.tag.inner
  • core.text-objects.textobject.tag.outer
  • core.text-objects.textobject.list.outer - around the entire list

Movable "items" include headings, and list items (ordered/unordered/todo)

Example

Example keybinds that would go in your Neorg configuration:

vim.keymap.set("n", "<up>", "<Plug>(neorg.text-objects.item-up)", {})
vim.keymap.set("n", "<down>", "<Plug>(neorg.text-objects.item-down)", {})
vim.keymap.set({ "o", "x" }, "iH", "<Plug>(neorg.text-objects.textobject.heading.inner)", {})
vim.keymap.set({ "o", "x" }, "aH", "<Plug>(neorg.text-objects.textobject.heading.outer)", {})

Configuration

  • moveables
    (table)

    • headings
      (list)

      • (string)
        "heading%d"
      • (string)
        "heading%d"
    • todo_items
      (list)

      • (string)
        "todo_item%d"
      • (list)
        • (string)
          "todo_item%d"
        • (string)
          "unordered_list%d"
    • unordered_list_elements
      (list)

      • (string)
        "unordered_list%d"
      • (list)
        • (string)
          "todo_item%d"
        • (string)
          "unordered_list%d"

Dependencies

Clone this wiki locally