Setting up Kate snippets

Kate is one of the best editors around and I have always felt most comfortable with it. It is very intuitive and at the same pleasing to the eye. Most of the gnome population haven’t heard of it and I feel it trumps gedit any day. (http://kate-editor.org/about-kate/)

Recently, I discovered that that there is not much online material available for snippets in Kate and after a little bit poking around, I finally got what I wanted. I felt that putting up a blog post would be a good idea too.

Setting up Kate snippets:

1. Open Kate. Go to Settings Menu. Click Configure Kate.

2.  Go to the Plugins tab. Enable Kate Snippets. You will notice that Kate Snippets tab appears automatically in the left pane.


3. Click the Kate Snippets tab on the left pane. You will observe a few sample snippets and also the option to add a New Snippet File. Click it.

4. As an example, I will be creating a snippet to help me with coding in C++ on SPOJ. So, I’ll give the snippet a name “C++ for SPOJ” and LGPL v2+ License. Of course, my name is Anirudh and I’ll give the same for Authors.

You will see a screen like this.

5. We wouldn’t inadvertently want our snippet to be applied for other type of files. So change the File type from * to C++. Click the button at the bottom-left to create a New Snippet. Set the Match/Name value in the right pane to spoj.

Insert the following in the Snippet Content:

#include <iostream>
using namespace std;

int main() {
	${cursor}
	return 0;
}

The ${cursor} informs Kate where your cursor should be, after inserting your snippet. You should end up with something like this.

6.Save the snippet, enable the snippet and go back to Kate. Save the file with .cpp extension. Now type spoj in your editor and press Ctrl+Space.. You will see a little drop down box showing suggestions. Just press Enter.

Voila! Your snippet works perfectly!

About these ads

2 Comments on “Setting up Kate snippets”

  1. Shankar says:

    Nice da, however vim would pwn kate anyday.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.