Skip to content

Emacs package to treat any buffer as a template with placeholders to fill-in

License

Notifications You must be signed in to change notification settings

oantolin/placeholder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Placeholder

This package provides a simple way to treat text in a buffer as a template with placeholders where text needs to be filled in. Any occurrence of <++> in the buffer is a placeholder. You can navigate among the placeholder with the placeholder-forward and placeholder-backward commands. They move the point to the next placeholder in the specified direction and delete the placeholder so you can immediately start typing the text that should replace it. However, if you call them again immediately after, they restore that occurrence of the placeholder and move to the next.

The placeholder in only <++> by default, it can be changed by customizing the placeholder-string variable.

A placeholder-insert command is also provided, to insert the placeholder string.

I suggest the following keybindings:

CommandKeybinding
placeholder-forwardC-S-n
placeholder-backwardC-S-p
placeholder-insertC-S-x (X marks the spot!)

When to use Placeholder over richer templating options?

Why not just use YASnippet or the built-in Skeletons or Tempo libraries? All of these great packages are much more featureful and ambitious than Placeholder, but they require defining the template in advance and arranging for some way to insert it in a buffer: naming the template or binding it to a key. This makes perfect sense for templates you plan to use many times, like for loops or CommonMark code blocks, or other things people typically make snippets for. But it can feel like too much work if you just want to leave some spots marked in your buffer to fill in later, or to make bespoke templates you only ever plan to use a few times. In those situations Placeholder might be a better fit.

For example, I often want to write several similar but not identical emails to different people. I write the first one right in the message buffer using placeholders and put the text in a register. Then I repeatedly insert the template, fill it out and send the email.

About

Emacs package to treat any buffer as a template with placeholders to fill-in

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published