Using Kate’s Snippets Plugin for Templates

Kate, KDE‘s advanced text editor, is a great tool when you need some advanced features, but don’t want to rely on something as advanced as vim or emacs. I’d been using it for a while since I’m a KDE fan, but I never actually knew about the Snippets feature until recently.

So, what does this do? Well, it allows you to insert blocks of code or text into something simply by picking it from the sidebar, or using Ctrl + Space and picking it from a list. If the sidebar doesn’t show up, you may need to enable it in Settings under the Plug-ins > Snippets Tool View.

How useful is this feature? Well, it lets you handle tedious typing tasks with just a few key presses or clicks, rather than having to copy-paste or manually type everything out. And this means you have the abiliy to make templates.

A good example is how I write these blog posts. Below is the template I use for my Pelican blog.

Title: 
Date: 
Tags: 
Author: TeraDyne Ezeri
Category: 
Status:

[0]:

It doesn’t seem like much, but with a couple of clicks, I put that in the codeblock. It saves quite a bit of time and energy.

To add a template, or even a code snippet, just right-click in the Snippets pane. If you don’t have a “snippets repository” set up yet, choose Add Repository to create one. This is the folder where you’ll be keeping your templates, so name it properly, and choose a namespace that will show up when you use Ctrl + Space to insert them. I use new for my templates, as I’m making a “new” document with them, so the menu lists new:blog for the template posted above, for example.

Once the repository is made, right-clicking on the folder you made gives you the option to Add Snippet.

social