Kate is the default KDE text editing application. Its history goes back to 2001, making it a veteran program in Linux terms. Although Kate, like Pluma. allows you to have several documents open at once, rather than displaying these in tabs it lists them in a separate Document panel at the left of the screen. This can be viewed in Tree Mode as a hierarchy, or List Mode as a flat list. Clicking on the name of a document will bring it to the front for editing.
In addition to the usual options, the Dolphin File menu includes ‘Close Orphaned’, which will remove any files from the Documents panel that have been deleted (or renamed) on the disk, and ‘Export as HTML’, which will add the necessary HTML codes to a text file for it to pass muster as a valid HTML5 web page. This includes the <pre> style used to display non-formatted text.
Edit and View Menus
The Dolphin Edit menu has some interesting entries:
- Block Selection Mode allows you to make a selection that doesn’t extend all the way across the page; e.g. you could select and copy only the third column in a five-column table.
- VI Input Mode refers to the ancient and famous (or infamous) UNIX text-based editor vi. Many early Linux developers grew up using vi daily and became very proficient with its keyboard codes and short cuts. For users from that generation who still want to capitalise on their vi skills, Kate can be set to respond to those vi commands.
- Overwrite Mode – new text in the middle of the document will overwrite existing text, rather than pushing it out of the way. The same function can be achieved in Kate (and other text editors) by toggling the Insert key.
- Find… Kate has a large range of text searching options. The first four will open a Find panel at the bottom of the screen where you can specify what to search for and any options to use. Kate supports full use of regular expression (regex) searching, so you can use wildcards and other special characters in your search if that option is on. Find Selected and Find Selected Backwards use the currently highlighted block of text as a search term. The Find All button in the panel will highlight every occurrence of the search term in the document.
- Go to Line allows you to move to any line in the document, where a ‘line’ is any block of text following an Enter character and finishing with an Enter character; a ‘paragraph’ in word processing parlance.
The View menu allows you to open a new instance of the program, to move back and forth between documents, and to split the screen as in Dolphin. Kate includes a vertical as well as a horizontal split, so you can see different sections of long documents. The splitter line can be moved with the mouse or with the commands under View/Split View. Tool Views controls the layout of the panels on the screen.
- View/Switch to Command Line opens up a mini-terminal panel at the bottom of the screen for one-off commands.
- View/Schema – Schemas are collections of fonts, colours, sizes, etc, which control the appearance of Kate on the screen – rather like simple ‘skins’ for the program. You can create and save these under Settings/Configure Kate/Fonts and Colors, and call them up with View/Schema when required.
- View/Dynamic Word Wrap – causes paragraphs that are too long to fit on the screen to wrap around rather than running off to the right. Word Wrap Indicators are small icons that appear at the left of each line, indicating that it’s a continuation of the previous one.
- View/Show Icon Border divides the grey margin at the left of the text vertically into two. Clicking in the left-hand side of the division places a small ‘priority’ star icon against that line.
- View/Show Line Numbers – places line numbers in the grey margin.
- Show Scrollbar Marks – When you add bookmarks to a document (see below), selecting this will cause the bookmark location to appear as a thin line across the right scrollbar, behind the position indicator.
Kate also supports code folding via the View menu – meaning that if you’re writing a program or computer script which falls into hierarchical sections and subsections, you can choose to expand or hide the subsections. Hide them all and you have an elegant program that steps simply from one major task to the next; open them all and you can see the exact details of what’s going on at that level. I will cover programming in Mint in Chapter 9; tools like Kate are an important aid.
A bookmark is a location in the currently active document. Clicking in the document and adding a bookmark at that point allows you to return to it later. All bookmarks are cleared when the document is closed.
Programmers – and others – sometimes need to work with several files at once. Rather than opening each one of these individually each time they start up, they can bind two or more documents together in a session, and open them all simultaneously. The Sessions menu makes it possible to save the currently open files and screen layout, and reopen them immediately in the future. The session name will appear at the beginning of the Kate title bar. You can use Settings/Configure Kate to open your previous session automatically when you start the application.
The Tools Menu
Kate has a vast range of tools, many of which are to do with programming activities. It can recognise many popular programming languages and provide assistance with using the correct keywords and indentation and getting the syntax right. For the ordinary user who just wants to compile a shopping list this is a bit much, but the potential is enormous. Here is a brief description of the items in Kate’s Tools menu:
- Pipe to Terminal – takes the text of the current document and feeds it to the Terminal as a sequence of commands, one line at a time.
- Synchronize Terminal with Current Document – moves the active directory for the built-in Terminal panel to the directory of the currently active document.
- Focus Terminal – Switches the cursor focus to the Terminal panel.
- Read-Only Mode – Locks the current document and prevents it from being changed.
- Mode, Highlighting and Indentation – If you’re writing a computer program or script, you can specify the language – i.e. ‘Mode’ – here and Kate will use the appropriate files for checking your input.
- Encoding – Makes other character sets available for typing text in non-European languages.
- End of Line – There is a big and irritating difference between the way that Windows-based programs and Linux programs deal with line endings in text files. The standard text file line ending in Windows is two special characters, a carriage return followed by a line feed, while in Linux it’s one special character, a line feed alone. This can cause major problems when text files created in one OS are opened in the other. Most Linux-based text editing programs recognise this and provide an option to convert to Windows conventions when saving the file. Kate has also provided this option under Tools as a separate command – plus an additional option for the Macintosh.
- Scripts – a handy set of commands for moving or copying blocks of text.
- Invoke Code Completion – if you’re working in a programming language that Kate recognises, and this option is turned on, you can start typing a keyword, then press Ctrl-Enter, and Kate will attempt to complete it for you.
- Word Completion – Like LibreOffice Writer, Kate will endeavour to guess what you mean to type when you start a long word. It has no dictionaries, however, so that guess will be based only on the other words in your document that start with the same letters. These will appear as entries in a pop-up menu which you can select by using the arrow keys or mouse and pressing Enter. Alternatively, you can use Ctrl-8 and Ctrl-9 to step through the alternatives in the list until you find the one you want.
- Spell checking (Normal Mode only) – Assuming you’re typing something in plain English (or some other language) and not a program or script, Kate can use a built-in dictionary to check your spelling. Non-recognised words are flagged with a wavy red underline, and right-clicking on them brings up the usual options: Ignore, Add to Dictionary, or replace with an alternative. You can also run a spell check that steps through the whole document.
- Clean Indentation – Regularises the indentation used for subsections of a script or program.
- Align – Moves a line left or right into its proper alignment. Commonly used for scripts and programs.
- Comment/Uncomment – Turns a line into a comment or vice versa, using the comment settings for the selected Mode.
- Uppercase, Lowercase, Capitalize – changes the case of selected text.
- Join Lines – connects two sequential lines into one.
- Apply Word Wrap – breaks a long line into chunks of a specified length by inserting line feed characters.
The Settings Menu
If there’s one thing that KDE developers do better than anything else, it’s providing settings. Like Dolphin, Kate comes with an insane number of settings that you can tweak to turn the program into something altogether different. And for some reason, a few ‘Show’ options and ‘View Full Screen’ have been tucked in here by default as well, when they should be under the View menu.
As with Dolphin, the settings include ‘Configure Shortcuts’, which allows you to associate (or disassociate) menu commands and certain keyboard combinations, and ‘Configure Toolbars’, which allows you to modify your toolbar layout by adding or removing buttons and moving them around, There are actually three toolbars listed, because the standard toolbar changes depending on what part of the screen you’re in.
The last entry, ‘Configure Kate’, opens a dialog box with two categories – ‘Application’ and ‘Editor Component’ – and five sub-categories under each, as follows:
- Application/General – What to do about loading documents that have been changed elsewhere, and how long to remember information about sessions.
- Application/Sessions – As mentioned above, sessions are a way of saving a particular layout and combination of documents. This panel controls how they are handled when Kate starts up.
- Application/Plugins – A set of additional tools which add extra capabilities to Kate, usually via extra toolbar buttons or menu entries. Users migrating from other text editing programs may find the Tab Bar plugins particularly useful.
- Application/Documents – Sets the colour of documents and the default View Mode.
- Application/Terminal – Can be set to link the Terminal panel with the current document’s location.
- Editor Component/Appearance – Controls the default settings for word wrap, indentation and line numbers, amongst other things.
- Editor Component/Fonts & Colours – As you would expect, this controls the default colours and typeface for new documents, including highlighting and the various kinds of keywords in programs and scripts.
- Editor Component/Editing – How the editor works. Includes AutoComplete and Spell Check options.
- Editor Component/Open/Save – Sets the default file save options, including the important line ending character.
- Editor Component/Extensions – Another, smaller set of pre-installed tools. They include a Thesaurus, but you’ll need to install additional software to make it work. Additional extensions and plugins for Kate can be downloaded from the Web.
Figure 29: Kate
Kate is a little intimidating for new users, but properly configured it can be incredibly powerful. When your text file requirements extend beyond preparing shopping lists you may want to give Kate a try – even if you’re not using KDE. Like Dolphin, Kate is hooked in to the KDE Help Centre via the Help menu.