# Working with the &kate; editor

## Overview

The &kate; editor is the editing area of the &kate; window. This editor is also used by &kwrite;, and it can be used in &konqueror; for displaying text files from your local computer, or from the network.

The editor is composed of the following components:

The editing area

  This is where the text of your document is located.

The Scroll bars

  The scroll bars indicate the position of the visible part of the document text, and can be used to move around the document. Dragging the scrollbars will not cause the insertion cursor to be moved.

  The scroll bars are displayed and hidden as required.

The Icon Border

  The icon border is a small pane on the left side of the editor, displaying a small icon next to marked lines.

  You can set or remove a bookmark in a visible line by clicking the &LMB; in the icon border next to that line.

  The display of the icon border can be toggled using the View Show Icon Border menu item.

The Line Numbers Pane

  The Line numbers pane shows the line numbers of all visible lines in the document.

  The display of the Line Numbers Pane can be toggled using the View Show Line Numbers menu item.

### Also in this Chapter:

- Navigating in the Text

- Working with the Selection

- Copying and Pasting Text

- Finding and Replacing Text

- Using Bookmarks

- Automatically Wrapping Text

## Navigating in the Text

This section is not yet documented.

## Working with the Selection

There are two basic ways of selecting text in &kate;: using the mouse, and using the keyboard.

To select using the mouse, hold down the &LMB; while dragging the mouse cursor from where the selection should start, to the desired end point. The text gets selected as you drag.

Double-clicking a word will select that word.

Triple-clicking in a line will select the entire line.

If &Shift; is held down while clicking, text will be selected:

- If nothing is already selected, from the text cursor position to the mouse cursor position.

- If there is a selection, from and including that selection to the mouse cursor position

When selecting text by dragging the mouse, the selected text is copied to the clipboard, and can be pasted by clicking the middle mouse button in the editor, or in any other application to which you want to paste the text.

To select using the keyboard, hold down the &Shift; key while using the navigation keys (The Arrow keys, Page Up, Page Down, Home and End, possibly in combination with &Ctrl; to extend the move of the text cursor).

See also the section Navigating in the Text in this Chapter.

To Copy the current selection, use the Edit Copy menu item or the keyboard shortcut (defaults to &Ctrl;C).

To Deselect the current selection, use the Edit Deselect menu item, or the keyboard shortcut (default is &Ctrl;&Shift;A), or click with the &LMB; in the editor.

### Using Block Selection

When Block Selection is enabled, you can make vertical selections in the text, meaning selecting limited columns from multiple lines. This is handy for working with tab separated lines for example.

Block Selection can be toggled using the Edit Toggle Block Selection menu item. The default keyboard shortcut is F4

### Using Overwrite Selection

If Overwrite Selection is enabled, typing or pasting text into the selection will cause the selected text to be replaced. If not enabled, new text will be added at the position of the text cursor.

Overwrite Selection is enabled by default.

To change the setting for this option, use the Select Page of the Configuration Dialog.

### Using Persistent Selection

When Persistent selection is enabled, typing characters or moving the cursor will not cause the Selection to become deselected. This means that you can move the cursor away from the selection and type text.

Persistent Selection is disabled by default.

Persistent Selection can be enabled in the Select Page of the Configuration Dialog.

If Persistent Selection and Overwrite Selection are both enabled, typing or pasting text when the text cursor is inside the selection will cause it to be replaced and deselected.

## Copying and Pasting Text

To copy text, select it and use the Edit Copy menu item. Additionally, selecting text with the mouse will cause selected text to be copied to the clipboard.

To paste the text currently in the clipboard, use the Edit Paste menu item.

Additionally, text selected with the mouse may be pasted by clicking the middle mouse button at the desired position.

If you are using the &kde; desktop, you can retrieve earlier copied text from any application using the &klipper; icon in the &kicker; icon tray.

## Finding and Replacing Text

### The Find Text and Replace Text Dialogs

The Find and Replace Text dialogs in &kate; are very much the same, except the Replace Text dialog offers the means of entering a replacement string along with a few extra options.

The dialogs offer the following common options:

Text to Find

  This is where to enter the search string. The interpretation of the string depends on some of the options described below.

Regular Expression

  If checked, the search string is interpreted as a regular expression. A button for using a graphical tool to create or edit the expression will be enabled.

  See Regular Expressions for more on these.

Case Insensitive

  If enabled, the search will be case insensitive.

Whole Words Only

  If checked, the search will only match if there is a word boundary at both ends of the string matching, meaning not an alphanumeric character - either some other visible character or a line end.

From Beginning

  If checked, the search will start at the beginning of the first line in the document, otherwise it will start at cursor position.

Find Backwards

  If checked, the search will look for the first match above the starting point, either cursor position or the beginning of the document, if the From Beginning option is enabled.

The Replace Text Dialog offers some additional options:

Replace With

  This is where to enter the replacement string.

Selected Text

  This option is disabled if no text is selected, or if the Prompt on Replace option is enabled. If checked, all matches of the search string within the selected text will be replaced with the replace string.

Prompt on Replace

  If checked, a small dialog will prompt you for what to do for each time a match is found. It offers the following options:

  Yes

    Activate this to replace the current match (which is selected in the editor).

  No

    Activate to skip the current match, and try to find another one.

  All

    Activate to cancel prompting, and just replace all matches.

  Close

    Activate this skip the current match and end the searching.

There is currently no way to use minimal matching when searching for a regular expression. This will be added in a future version of &kate;

### Finding Text

To find text, launch the Find Text Dialog with &Ctrl;For from the Edit Find... menu item,enter a search string, set the options as desired and hit Ok. If no matches is found between the starting point for the search (either the text cursor position or the beginning of the document) you will be prompted for permission to continue from the start (or end, if you are searching backwards) of the document.

If a match is found it is selected and the Find Text Dialog is hidden, but stay tuned, finding further matches is very easy:

To find the next match in the search direction, use the Edit Find Next command or press F3.

To find the next match in the opposite direction, use the Edit Find Previous command or press &Shift;F3.

If no match is found before reaching the document border, you will be prompted for permission to cross that.

### Replacing Text

To replace text, launch the Replace text Dialog using the Edit Replace command, or the &Ctrl;R shortcut, enter a search string and optionally a replace string (if the replace string is empty, each match will be replaced with ""), set the options as desired and hit the Ok button.

If you are using a regular expression to find the text to replace, you can employ backrefences to reuse text captured in parenthesized subpatterns of the expression.

See for more on those.

## Using Bookmarks

The bookmarks feature allows you to mark certain lines, to be able to easily find them again.

You can set or remove a bookmark in a line in two ways:

- Moving the insertion cursor to that line, and activate the Bookmarks Toggle Bookmark (&Ctrl;B) command.

- Clicking in the Icon Border next to that line.

Bookmarks are available in the Bookmarks menu. The individual bookmarks are available as menu items, labeled with the line number of the line with the bookmark, and the first few characters of the text in the line. To move the insertion cursor to the beginning of a bookmarked line, open the menu and select the bookmark.

If the Reopen Files option in the Config Dialog is enabled (or if &kate; was started by the session manager), your bookmarks will be restored when the document is reopened.

## Automatically Wrapping text

This feature allows you to have the text formatted in a very simple way: the text will be wrapped, so that no lines exceed a maximum number of characters per line, unless there is a longer string of non-whitespace characters.

To enable/disable it, check/uncheck the Word Wrap checkbox in the edit page of the configuration dialog.

To set the maximum line width (maximum characters per line), use the Wrap Words At option in the edit page of the configuration dialog.

If enabled, it has the following effects:

- While typing, the editor will automatically insert a hard line break after the last whitespace character at a position before the maximum line width is reached.

- While loading a document, the editor will wrap the text in a similar way, so that no lines are longer than the maximum line width, if they contain any whitespace allowing that.

There is currently no way to set word wrap for document types, or even to enable or disable the feature on document level. This will be fixed in a future version of &kate;