Text editor with predefined text snippets?

I do a lot of text editing for work and there are some phrases that I have to type frequently. What’s the best way to quickly paste those phrases into a document using a shortcut or keyword? I mainly use Kwrite and Kate as i prefer plain text editors and need no formatting.

beeng,

CopyQ

mfat,

Looks good, thanks!

Pantherina,

Kate snippets. If you download them you think “huh do I need to know XML or what?”

But just install the extension and everything has a nice GUI

Daeraxa,

Pulsar (i.e. active fork of Atom) has a pretty comprehensive snippets package that comes bundled with the editor. Can be configured with some fairly simple cson, for example with Markdown:


<span style="color:#323232;">'.source.gfm':
</span><span style="color:#323232;">  'Hello Lemmy':
</span><span style="color:#323232;">    'prefix': 'helem'
</span><span style="color:#323232;">    'body': 'Hello Lemmy!'
</span>

You type helem then press tab and it will expand to Hello Lemmy! when using the Markdown grammar (source.gfm).
It can handle custom tab stops too so you can make a longer preformatted sentence with gaps to insert words which you can just tab through (the $1, $2, $3).


<span style="color:#323232;">'.source.gfm':
</span><span style="color:#323232;">  'My custom snippet':
</span><span style="color:#323232;">    'prefix': 'mcs'
</span><span style="color:#323232;">    'body': 'My snippet stops here $1 and then here $2 and then continues $3'
</span>

You can even do multi-line snippets. For anyone wanting to try it out the docs are here

z00s,

I’ve used Autokey with great success in the past. Easy to set up, just works.

ShittyBeatlesFCPres,

I use Autokey because I prefer a global snippets engine. Then it works in text editors, browsers, email clients, etc.

jlow,

Check out Espanso, if you’re ok with something that is system-wide and not a text-editor:

espanso.org

antsu,

+1

TerkErJerbs,

+1 for Espanso. Great tool, use it every day.

d3Xt3r,

Seconded. I love that it works under Wayland too, unlike Autokey.

jlow,

Yeah, the install is a bit more involved under Walyand bit it does work like a charm.

kbal,
@kbal@kbin.melroy.org avatar

Vim macros are quite easy to use, if you already know how to vi.

ouch,

Besides macros, I think vim had some other relevant feature for this. Just can’t remember it right now.

overkill,

I use (neo)vim with UltiSnips for coding, text editing and writing e-mails, and it works great! It’s super customizable.

zygo_histo_morpheus,

UltiSnips is fantastic

overkill,

Yeah with its flags / regex / python support UltiSnips is really the gold standard of a snippet engine. In many other environments “snippets” really just means “substitute one string for another”, where UltiSnips is so much more!

sloppy_diffuser,

Might be a plugin. I think I’m using friendly-snippets (whatever is in LazyVim). There is also LuaSnip. They feed into my auto completion plugin as one of several sources.

Zak,
@Zak@lemmy.world avatar

I mainly use Kwrite and Kate

Kate Snippets

mrh, (edited )
@mrh@mander.xyz avatar

If I understand you correctly, this is trivial in emacs:


<span style="color:#323232;">(</span><span style="font-weight:bold;color:#a71d5d;">defun </span><span style="font-weight:bold;color:#795da3;">insert-text </span><span style="color:#323232;">()
</span><span style="color:#323232;">  (interactive)
</span><span style="color:#323232;">  (insert </span><span style="color:#183691;">"your text here"</span><span style="color:#323232;">))
</span><span style="color:#323232;">
</span><span style="color:#323232;">(global</span><span style="font-weight:bold;color:#a71d5d;">-</span><span style="color:#62a35c;">set</span><span style="font-weight:bold;color:#a71d5d;">-</span><span style="color:#323232;">key your</span><span style="font-weight:bold;color:#a71d5d;">-</span><span style="color:#323232;">keybind</span><span style="font-weight:bold;color:#a71d5d;">-</span><span style="color:#323232;">here </span><span style="color:#0086b3;">#'insert-text</span><span style="color:#323232;">)
</span>

You could make it a format string if it relies on data specific to some file or parameter. You could also make the keybind local to certain modes/files rather than a global keybind if you don’t want to pollute your keybind space.

Zak,
@Zak@lemmy.world avatar

Emacs has several templating/snippet packages available, such as YASnippet.

Octorine,

There’s a built in snippet system too, called skeletons, but most people seem to prefer the yasnippet interface.

cabhan,

Depending on the complexity, there’s also abbrev-mode: www.gnu.org/software/emacs/manual/…/Abbrevs.html

stale_cheetos,

Visual Studio Code has this feature. You can define user snippets using a JSON format and create any alias you like for each. Then, when editing a document you just start typing the alias and press tab when it suggests the snippet (no mousing around required).

You can also create anchor points for variable content that you then tab through and fill out after inserting a snippet. If you find yourself using the same template for your writing this might be a helpful feature.

I’m bad at describing things, here’s some documentation: code.visualstudio.com/docs/…/userdefinedsnippets.

This is all out of the box with no plugins installed. Also, I’ll point out that although the docs are coding related, you can make these work for any type of writing.

bo5on,

Autokey?

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • DreamBathrooms
  • mdbf
  • ethstaker
  • magazineikmin
  • cubers
  • rosin
  • thenastyranch
  • Youngstown
  • InstantRegret
  • slotface
  • osvaldo12
  • kavyap
  • khanakhh
  • Durango
  • megavids
  • everett
  • tacticalgear
  • modclub
  • normalnudes
  • ngwrru68w68
  • cisconetworking
  • tester
  • GTA5RPClips
  • Leos
  • anitta
  • provamag3
  • JUstTest
  • lostlight
  • All magazines