Custom Search

Thursday, February 23, 2012

Expert Tips and Tricks With Kate and Konsole

The Kate graphical text editor and Konsole graphical terminal emulator are chock-full of advanced features and time-saving shortcuts. They work nicely together to make the lives of system administrators, writers, users, and programmers easier. Here is a look at some of the ways to make these power tools work for you.

Simplicity

Let's have a little chat about simplicity first, because I think this is quite misunderstood. A personal computer is a mighty all-purpose beast that serves whatever role you can imagine, and Linux is the most flexible computing platform of all, for everything from tiny embedded devices to supercomputers. The average low-budget PC outperforms the supercomputers of yesteryear.

This vast flexibility can be rather daunting, and one approach to managing it is to strip away functionality and hide what it's doing from the fragile eyes of the user. That is supposed to make it easier for us. I think it makes it harder because then we're stuck with an inflexible, opaque system that we cannot tailor to our own needs, and we have to invest time and ingenuity in working around the shortcomings of the "simplified" system.

Real simplicity is when we can tailor software applications to suit our needs, and to support an efficient, fast workflow. Workflow is everything, because every redundant keystroke and mouse click and inefficiency multiplies with every use. Life is too short to waste on clunky dumb tools that waste our time.

Kate

And so we segue nicely to Kate, the über KDE graphical text editor. I do most of my writing in Kate. I used to rely on Vim, which I still like and use on the console, but Kate has won my heart for most writing chores.

Kate has the advantages of a graphical interface so you have both keyboard and mouse, a graphical file picker, graphical configuration menus, and an integrated Konsole window. Figure 1 shows what all this looks like.Figure 1: Kate with three files and the integrated Konsole window open.

My first task with a new Kate is to customize the keyboard shortcuts with Settings -> Configure Shortcuts. You can control everything in Kate from the keyboard. Vi/Vim fans can set it to Vi Input Mode, which doesn't include all of Vi's mighty power tools like autotext, abbreviations, or mappings. But it does include a lot of mode and navigation commands.

Kate has keyboard controls for zoom, Forward and Back in the document tree, New File, New Window, Delete Line, Delete Word Left/Right, Select Page Up/Down, Select to End of Document, Select to End of Line, and many more. I don't try to remember keyboard shortcuts for every last little thing, but rather for the tasks that I do the most. Kate even support multiple keyboard shortcut schemes, which you can set up by clicking the Details button at the bottom of the Configure Shortcuts window.

Kate supports sessions, which you set up in the Sessions menu. This is a super time-saving feature for multiple-document projects because you can save all the documents and window configuration, including split views, in a single session. kate -s sessionname opens Kate to your chosen session, or creates a new one.

Speaking of multiple documents, you can use View -> Split View to see multiple documents at once, as many as you want, stacked either vertically or horizontally, and you can drag the splitter between the documents to resize them. When you close a split view the document remains open.

Kate comes with syntax highlighting and modes for dozens of scripting and programming languages (Tools > Mode/Highlighting), including some unusual ones like Lilypond, Wesnoth Markup Language for the Battle of Wesnoth game, MatLab, and POV-Ray.

When you're navigating a long complex document Kate's bookmarks will save your bacon every time, and the feature I love most is Ctrl+ Up/Down arrow, which scrolls up and down without moving the cursor. Kate does code folding, which is temporarily hiding sections of code, and you can automatically comment out a section of code by selecting it and then pressing Ctrl+d. Un-comment it with Ctrl+Shift+d. Another feature I use a lot is File -> Open With whatever external application I want. When I'm writing Web articles I use it to preview my work in a Web browser.

Tools -> Synchronize Terminal With Current Document makes the built-in terminal change to current working directory of the open document.

Kate has a bunch of nice plugins that you can activate via Settings -> Configure Kate -> Applications -> Plugins, and extensions via Settings -> Configure Kate -> Editor Component -> Extensions.

There is one conspicuously missing feature, and that is word count. I open the terminal, sync to the current document, and run wc -w filename. It's clunky but it works.

There are a whole lot more things Kate can do which you can find by poking around in the menus, and the Kate Handbook is helpful.

Konsole

Konsole is the KDE4 graphical terminal emulator, and it also supports keyboard shortcuts for all operations, profiles, bookmarks, and split views. Let's start with View -> Split View, which is a source of confusion because the split is a clone, not an independent window.

The purpose of this is to give two views of the same document or whatever output you are monitoring. For example, suppose you are studying a long configuration file. The split view shows the same document in both panes, but you can scroll independently to bring up different sections of the document side-by-side. Just like Kate you can open as many splits as you want.

Konsole's Bookmarks menu is a nice time-saver, because you can bookmark any directory just like bookmarking Web sites in a Web browser, and you can bookmark all open tabs in a single folder (figure 2). It also supports ssh and telnet sessions, for example ssh://carla@server, or telnet://carla@otherserver.

Figure 2: Creating a new Konsole bookmark.

You can use Edit -> Copy Input To all open tabs in the current window, or selected tabs in the current window. This is useful, to give one example, for running the same commands on multiple hosts at the same time over SSH. I would like it even better if it supported multiple windows instead of tabs so I could see everything at once, but it doesn't.

File -> Save Output As operates like the tee command; it sends all screen output to a text file while it displays the same output on the screen. This is a great way to create an audit trail so you can go back and see what the heck you did.

Want to select columns of your screen output? Press Ctrl+Alt while selecting with the mouse.

Double-clicking selects a single word, and on the Advanced tab of the profile configuration dialog you can configure which characters should be considered part of word, such as the hyphen, tilde, hash mark, or any mark you want included in a double-click word selection. Triple-click selects a line.

While you're in the profile configurator, check out the General tab – this has some useful basic tweaks, plus you can set the default directory to open to.

You can always do the quick Unix-style copy and paste of select with mouse/middle-click paste, and can also copy with Ctrl+Shift+c, and paste with Ctrl+Shift+Insert.

There many more useful features in both Kate and Konsole, such as scripting support and command-line operations. Please visit the Kate Editor Homepage and Konsole to learn more about these excellent applications.



busy

No comments:

Post a Comment