Skip to content

moisestohias/Sublime-Text-WikiLinks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

WikiLinks Plugin for Sublime Text

A Sublime Text Plugin that provides wiki-style link navigation for text files. Similar functionality to obsidian, allowing linking files using [[filename]] syntax and navigate between them with hover previews and keyboard shortcuts.

"In Obsidian, a [[wiki link]] is a way to create internal links between notes using a specific syntax: [[Note Title]]. This allows for easy navigation between notes and is the default linking method in Obsidian. While it's not part of the standard Markdown specification, it's widely supported by many other apps for linking within the same knowledge base"

Features

  • Hover Previews: Hover over wiki links to see file previews in a popup
  • Click Navigation: Ctrl+click on links to open files
  • Keyboard Navigation: Alt+Enter to navigate to link at cursor
  • Auto File Creation: Creates new files when navigating to non-existent links
  • Multi-format Support: Automatically searches for files with common extensions (.txt, .md, .py, .html, .css, .js)
  • Workspace Integration: Searches all folders in your Sublime Text workspace

Usage

Creating Wiki Links

Create links to other files using double square brackets:

Some text then boom a [[filename]], this allows you to embed link similar to [[Obsidian]] wiki link feature.
And other [[Idea-Name]]
[[project/documentation]]

Link Formats

The plugin supports several link formats:

  1. Basic links: [[filename]] - Searches for files with common extensions
  2. Relative paths: [[main/Adjectives]], [[English/main/Adjectives]] - Paths relative to current file or workspace
  3. Explicit extensions: [[Adjectives.md]], [[notes.txt]] - Files with specific extensions
  4. Fragment identifiers: [[Adjectives#Section-one]] - Links to specific sections
  5. Combined: [[main/Adjectives.md#Grammar-Rules]] - Path, extension, and section

Navigation Methods

  1. Hover Preview: Simply hover your mouse over any wiki link to see a preview popup showing the first 15 lines of the target file
  2. Ctrl+Click: Hold Ctrl and click on any wiki link to open the target file
  3. Keyboard Shortcut: Place your cursor on a wiki link and press Alt+Enter to navigate

File Resolution

The plugin searches for files in this order:

  1. Relative to current file: If the link contains a path (e.g., [[main/Adjectives]]), it first tries relative to the current file's directory
  2. Exact filename match in workspace: Searches all workspace folders for the exact path
  3. Filename with common extensions: If no extension is specified, tries .txt, .md, .py, .html, .css, .js
  4. Recursive search: For simple filenames (no path), recursively searches all workspace folders
  5. File creation: If no file is found, creates a new file (defaults to .md extension if none specified)

Fragment/Section Navigation

When using fragment identifiers (e.g., [[document#section-name]]):

  • The plugin searches for markdown headers matching the fragment name
  • Supports headers at any level (#, ##, ###, etc.)
  • Also matches plain text lines that exactly match the fragment
  • Handles hyphens and underscores as word separators (e.g., section-name matches Section Name)
  • When creating a new file with a fragment, it automatically adds a markdown header

Examples

This is a link to [[my-project-notes]].
You can also link to [[subfolder/specific-file]].
Links without extensions [[todo]] will search for todo.txt, todo.md, etc.
Links with extensions [[notes.md]] will open that exact file.
Fragment links [[document#section-name]] navigate to specific sections.

Installation

  1. Save the plugin file as WikiLinks.py in your Sublime Text Packages/User directory
  2. Add the key binding to your user key bindings file (Preferences → Key Bindings):
[
    {
        "keys": ["alt+enter"],
        "command": "wiki_link_navigate_at_cursor",
        "context": [
            {"key": "selector", "operator": "equal", "operand": "text"}
        ]
    }
]
  1. Restart Sublime Text or reload the plugin

Technical Details

Commands Available

  • wiki_link_navigate_at_cursor: Navigate to wiki link at current cursor position

File Search Logic

  1. Checks current workspace folders first
  2. Falls back to current file's directory if no workspace is open
  3. Supports both relative and absolute path references
  4. Automatically appends common file extensions if none specified

Preview Features

  • Shows first 15 lines of target files
  • HTML-escaped content for safe display
  • Scrollable preview for longer content
  • Error handling for unreadable files

Troubleshooting

Links not working: Ensure your files are in the current workspace or in the same directory as your current file.

Preview not showing: Check that the target file exists and is readable.

Keyboard shortcut conflicts: Modify the key binding in your user settings if Alt+Enter conflicts with other plugins.

File Structure Example

project/
├── index.md          # Contains [[notes]] and [[todo]]
├── notes.md          # Contains [[project/details]] and [[main/Adjectives#Grammar]]
├── todo.txt
├── main/
│   └── Adjectives.md # Contains ## Grammar section
└── project/
    └── details.md

With this structure, all wiki links will resolve correctly and you can navigate between files seamlessly.

Supported Link Patterns

  • [[notes]] → searches for notes.txt, notes.md, etc.
  • [[project/details]] → relative path from workspace or current file
  • [[main/Adjectives.md]] → explicit extension
  • [[main/Adjectives#Grammar]] → navigates to ## Grammar section
  • [[Adjectives#section-name]] → searches workspace and navigates to section

About

Obsidian [[wiki link]] for Sublime Text

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages