Using Kate As a Web Editor

There are many applications out there that provide project-based web development tools and very feature-rich interfaces, but sometimes all you really need is a good text editor. For those times, there are few editors that can stand up to the KDE powerhouse called Kate.

Kate is a multi-document interface (MDI) text editor, available for both KDE 3 and 4. It runs on multiple Linux and Unix-like platforms, Mac OS X, and  Windows. It also includes a component called KatePart, which runs inside numerous other KDE applications, including Quanta+ (on KDE 3 only), KWrite, Konqueror, and Kdevelop. Kate provides syntax highlighting for over 120 text formats, making it perfect for whatever programming language you choose.

HTML Editing

kate-php

Kate will highlight HTML markup and underline errors, particularly when you forget to close a tag.  It will also group text within tags, so that you can see what content is where. It will display folding markers, small arrows on the side, that you can use to collapse or expand a tag and its contents. To toggle folding markers, press F9. For that reason, if you are coding in XHTML, make sure to use the XML highlighting rather than HTML.  It will then appropriately mark single tags that are not closed with arrows.

Kate folding markers

To enable XML highlighting:

1. Click Tools in the main menu
2. Navigate to “Highlighting”, “Markup”, and finally to “XML”.

You can also do the same for PHP and other web scripting languages. Kate will generally highlight all of these, so you can usually leave the settings at the default.

Kate includes a dynamic word wrap feature, useful for documents with large amounts of text. Toggle it on or off with F10. Press F11 to toggle line numbers, and you will notice that a wrapped line has symbols indicating that it is still part of the previous line.

Multiple Documents

With Kate, you can edit multiple documents at once. The left-hand column will display the list of currently opened files, and you can move through them by clicking on the file you want to edit, by clicking the forward or back buttons, or by holding the Alt key and pressing the left or right arrow. Control+S will save your current document, and Control+L will save all open documents.

Sessions

Kate has a handy feature called “Sessions” that allows you to pick up work right where you left off the last time you were editing. For example, you might have eight documents for a particular project. Rather than having to open each document one at a time every time you want to work on them, you can save a Kate session that will automatically open those documents when activated. To save a session:

1. Click Sessions
2. Click Save As…
3. Give your session a name.

Kate session chooser

The next time you want to return to that project, just open the session you saved.

Remote Editing

There are times when you need to edit a document quickly right on the server. While you could SSH into the server and use whatever text editor is available from the command line, you will miss some of the many benefits of Kate. Furthermore, if you have a shared hosting account, you might not even have access to SSH.  With Kate, you can open a document live on the server via FTP, SFTP, and any other protocol supported by KDE. To accomplish this, do the following:

1. Login to your web server using the normal method. You can use Dolphin or Konqueror.
2. Navigate to the folder containing the file you want to edit.
3. Right click on the file and open it with Kate.
4. Repeat those steps for multiple files if necessary.

Find

Kate’s find feature is very useful with long documents. To activate it, press Control-F. It will open a dialog at the bottom of the window. You can find each instance individually and scroll through the results with the “Next” and “Previous” buttons, or click “Options” and “Highlight all” to see all results highlighted at once.

Click the arrow on the far right to expand the find dialog further, and it will add a “replace” feature. With it you can find a tag or piece of content and replace every instance of it with something else or nothing at all.  Kate will also remember your searches so that you can perform them again by pressing the down arrow on the right side of the search box.

I have only touched the surface of the many features available in Kate. The best way to find out exactly what Kate can offer you is to try it out for yourself. I highly recommend it, not only for KDE users, but for anyone. Kate is available through any Linux distribution that offers KDE.