Skip to content

Templater cuts off first letter of Snippets in Slash Command Menu #1686

@motion2082

Description

@motion2082

Templater Bug Report: First Character Removed from Snippet Template Command Names

Bug Description

When creating hotkey-enabled template snippets, Templater removes the first character from the template filename when displaying the command name in the command palette.

Steps to Reproduce

  1. Create a template file: 06 Toolkit/Snippets/Quote Snippet Template.md
  2. Enable it as a hotkey template in Templater settings
  3. Open command palette (Ctrl/Cmd + P)
  4. Search for "Templater: Insert"
  5. Observe: Command shows as "Templater: Insert uote Snippet Template" (Q is missing)

Expected Behavior

Command should display as: Templater: Insert Quote Snippet Template

Actual Behavior

Command displays as: Templater: Insert uote Snippet Template

Root Cause (Investigation)

The bug appears to be in the command name generation logic where Templater calls .slice(1) on the template basename:

// Current (buggy) behavior
const basename = path.split('/').pop().replace('.md', '');
commandName = 'Templater: Insert ' + basename.slice(1);  // BUG: removes first char

Should be:

commandName = 'Templater: Insert ' + basename;  // No slice needed

Affected Files

All snippet templates show this behavior:

  • "Quote Snippet Template.md" → "uote Snippet Template"
  • "Callout Snippet.md" → "allout Snippet"
  • "Heading 1 Snippet Template.md" → "eading 1 Snippet Template"

Environment

  • Templater version: 2.16.4
  • Obsidian version: (latest)
  • Platform: Windows/Mac/Linux

Workaround

Prefix template filenames with an underscore:

  • _Quote Snippet Template.md displays correctly as "Quote Snippet Template"

Impact

  • Confusing command palette entries
  • Makes it harder to find the right snippet
  • Workaround requires renaming all snippet files

Suggested Fix

Remove the .slice(1) call from the basename when generating command names for template snippets.


Related Code Location: Likely in the function that registers template hotkey commands in main.js (minified in production build)

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueA good issue for someone who wants to contribute

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions