# File's Link Picker

**URL:** <https://community.silverbullet.md/t/files-link-picker/3608>\
**Category:** Plugs and Libraries\
**Created:** [December 3, 2025, 6:13pm UTC](https://community.silverbullet.md/t/files-link-picker/3608 "2025-12-03T18:13:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChenZhu-Xie](https://community.silverbullet.md/user_avatar/community.silverbullet.md/chenzhu-xie/32/1476_2.png) [@ChenZhu-Xie](https://community.silverbullet.md/u/ChenZhu-Xie)\
**Post date:** [December 3, 2025, 6:13pm UTC](https://community.silverbullet.md/t/files-link-picker/3608/1 "2025-12-03T18:13:23Z")

</div>

# File’s Link Picker

`Alt-f` here we go

 ![image](https://community.silverbullet.md/uploads/default/original/2X/2/2814c8f4c23cc94221c9bb2c12d877be54218739.png)

# Realization

first **def** a global func `getFileLinks()`

```auto
function getFileLinks()
  return query[[
    from index.tag "link"
    where _.toFile
    select{
      ref = _.ref,
      snippet = _.snippet,
      page = _.page,
      pos = _.pos,
    }
    order by _.page, _.pos
  ]]
end

```

then create the `File Link Picker`

```auto
function navigateToPos(ref, pos)
  if ref then
    editor.navigate(ref)
    if pos then
      editor.moveCursor(tonumber(pos), true)
    end
    return true
  end
  return false
end

command.define {
  name = "Navigate: File Link Picker",
  key = "Alt-f",
  priority = 1,
  run = function()
    local tables = getFileLinks()
    if not tables or #tables == 0 then
      editor.flashNotification("No File Links found.")
      return
    end

    local items = {}
    for _, r in ipairs(tables) do
      table.insert(items, {
        name = r.snippet,
        description = string.format("%s @ %d", r.page, r.pos),
        ref = r.ref,
        page = r.page,
        pos = r.pos
      })
    end
    
    local sel = editor.filterBox("🔍 Select", items, "Choose a File Link...", "a File Link to GoTo")
    if not sel then return end

    if not navigateToPos(sel.ref, sel.pos) then
      editor.flashNotification("Failed to navigate to selected File Link.")
    end
  end
}

```

---

<div class="post-metadata">

**Author:** ![ChenZhu-Xie](https://community.silverbullet.md/user_avatar/community.silverbullet.md/chenzhu-xie/32/1476_2.png) [@ChenZhu-Xie](https://community.silverbullet.md/u/ChenZhu-Xie)\
**Post date:** [December 3, 2025, 6:33pm UTC](https://community.silverbullet.md/t/files-link-picker/3608/2 "2025-12-03T18:33:37Z")

</div>

My attempt to locate online images like `![](https://aituyaa.com/assets/Pasted%20image%2020250110153326.png)` in my SB instance ended up producing this `![[abcdefg.suffix]]` along with `[[abcdefg.suffix]]` picker unintentionally.

My original goal was an online-image picker, but such images are not regarded as indexable objects.

This suggests we may convert these `!()[abcdefg.suffix]`s into objects, or perhaps objectify everything (extending the [built-in tags](https://silverbullet.md/Object#Built-in%20tags) list)? and may further require some [real SQL support](https://community.silverbullet.md/t/data-schemas-and-real-sql/3110).

For now, one expedient method is to add a label/anchor (or any [built-in tag](https://silverbullet.md/Object#Built-in%20tags)) to/alongside each online image link `!()[abcdefg.suffix]` and rely on the [Anchor/Label Picker](https://community.silverbullet.md/t/abc-accurate-bi-directional-cursor-level-linking-system/3536/20) to query them, though this solution feels inelegant despite its generality.

> this `![[name.suffix]] Picker` is slightly different from the built-in `Document Picker`…

---

<div class="post-metadata">

**Author:** ![ChenZhu-Xie](https://community.silverbullet.md/user_avatar/community.silverbullet.md/chenzhu-xie/32/1476_2.png) [@ChenZhu-Xie](https://community.silverbullet.md/u/ChenZhu-Xie)\
**Post date:** [December 4, 2025, 8:52am UTC](https://community.silverbullet.md/t/files-link-picker/3608/3 "2025-12-04T08:52:27Z")

</div>

cleaned up

```auto
command.define {
  name = "Navigate: File Link Picker",
  key = "Alt-f",
  priority = 1,
  run = function()
    local FileLinks = getFileLinks()
    if not FileLinks or #FileLinks == 0 then
      editor.flashNotification("No File Links found.")
      return
    end
    
    local sel = editor.filterBox("🔍 Select", FileLinks, "Choose a File Link...", "a File Link to GoTo")
    if not sel then return end
    editor.navigate(sel.ref)
    editor.invokeCommand("Navigate: Center Cursor")
  end
}

function getFileLinks()
  return query[[
    from index.tag "link"
    where _.toFile
    select{
      name = _.snippet,
      description = string.format("%s @ %d", _.page, _.pos),
      ref = _.ref,
    }
    order by _.page, _.pos
  ]]
end

```
