&Anders.Lund; &Anders.Lund.mail;&tde-authors;Working with the &kate; editorOverviewThe &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 areaThis is where the text of your document is located.The Scroll barsThe 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 BorderThe 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
ViewShow/Hide Icon
Border menu item.The Line Numbers PaneThe Line Numbers Pane shows the line number of all visible
lines in the document.The display of the Line Numbers Pane can be toggled using the
ViewShow/Hide Line
Numbers menu item.The Folding PaneThe folding pane allows you to collapse or expand foldable blocks
of lines. The calculation of the foldable regions are done according to
rules in the syntax highlight definition for the document.Also in this Chapter:Navigating in the
Text Working with the
SelectionCopying and
Pasting TextFinding and
Replacing TextUsing
BookmarksAutomatically
Wrapping TextUsing automatic indentingNavigating in the TextMoving around the text in &kate; is like in most graphical text
editors. You move the cursor using the arrow keys and the
Page Up, Page Down, Home and
End keys in combination with the Ctrl and
Shift modifiers. The Shift key is always used
to generate a selection, while the Ctrl key have different
effects on different keys:
For the Up and Down keys it
means scroll rather than move the cursor.For the Left and Right
keys it means skip words rather than characters.for the Page Up and Page Down
keys it means move to the visible edge of the view rather than browse.For the Home and End keys it
means move to the beginning or end of the document rather than the beginning or
end of the line.&kate; also provides you with a way to quickly jump to a matching brace
or paranthesis. Place the cursor on the inside of a parenthesis or brace
character, and press Ctrl6
to jump to the matching parenthesis or brace.In addition you can use
bookmarks to quickly jump to
positions that you define on your own.Working with the SelectionThere are two basic ways of selecting text in &kate;: using the
mouse and using the keyboard.To select text using the mouse, hold down the &LMB; while dragging
the mouse cursor from the point 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 as follow:If nothing is already selected, from the text cursor
position to the mouse cursor position.If there is already a selection, from the selection start point
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 text 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
EditCopy menu item or the keyboard
shortcut (defaults to &Ctrl;C).To deselect the current selection, use the
EditDeselect menu item, or the
keyboard shortcut (default is &Ctrl;&Shift;A), or click
with the &LMB; in the editor.Using Block SelectionWhen the Block Selection Mode 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 Mode can be toggled using the
EditBlock Selection Mode menu item. The default keyboard
shortcut is &Ctrl;&Shift;B.Using Normal Selection ModeIf Normal Selection Mode 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.Normal Selection Mode is enabled by default.To change the setting for this option, use the Cursor & Selection page of the configuration dialog.Using Persistent Selection ModeWhen Persistent Selection Mode 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 Mode is disabled by default.Persistent Selection Mode can be enabled in the Cursor & Selection page of the configuration dialog.Copying and Pasting TextTo copy text, select it and use the
EditCopy 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
EditPaste
menu item.Additionally, text selected with the mouse may be pasted by
clicking the middle mouse button at the
desired position.You can also retrieve earlier copied text from any application using
the &klipper; icon in the &kicker; icon tray.Finding and Replacing TextThe Find Text and Replace
Text DialogsThe 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 FindThis is where to enter the search string. The interpretation of the string
depends on some of the options described below.Regular expressionIf 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 sensitiveIf enabled, the search will be case sensitive.Whole words onlyIf checked, the search will only match if there is a word
boundary at both ends of the string matching, meaning neither an
alphanumeric character, nor some other visible characters, nor a line
end.From cursorIf checked, the search will start at the current cursor position,
otherwise it will start at the beginning of the document.Find backwardsIf checked, the search will look for the first match above the
starting point, either the cursor position or the beginning of the
document depending on the status of the From cursor option.Selected textThis option is not available if no text is selected.
If some text has been selected and the option is checked, the
search string will be matched only against the selected text.The Replace Text dialog offers some
additional options:Replace WithThis is where to enter the replacement string.Use placeholdersWhen regular expressions are enabled, you can select part of the searched text by enclosing it
within parenthesis. Placeholders allow you to insert such text in the replacement string, similar to
how backreferences are used in sed. When enabled, any occurrence of \N (where
N is an integer number, e.g. \1, \2, ...) will be replaced
with the corresponding string capture (parenthesized substring)
from the search pattern. A button for listing all available string captures
will also be enabled. You can click on any of the available string captures
to include them in your replacement string.Placeholders can only be used when searching using regular expressions.Prompt on replaceIf checked, a small dialog will prompt you for what to
do for each time a match is found. It offers the following options:
ReplaceUse this button to replace the current match, which is
selected in the editor. After the replacement, search for the next match
automatically.Replace & CloseUse this button to replace the current match, which is
selected in the editor. After the replacement, close the dialog.Replace AllUse this button to replace all matches without further prompt.Find nextUse this button to skip replacing the current match and try to find the next one.CloseUse this button to skip replacing the current match and close the dialog.Finding TextTo find text, launch the Find Text dialog
with &Ctrl;F or
from the EditFind... menu item, enter a
search string, set the options as desired and hit the
Find button.If a match is found it is selected and the Find
Text dialog is hidden. Finding further
matches is very easy.To find the next match in the search direction, use the
EditFind
Next command or press
F3.To find the next match in the opposite direction, use the
EditFind
Previous command or press &Shift;F3.If no match is found before reaching the document end (or beginning if you
are searching backward), you will be asked if you want to continue the search
from the other end of the document.Replacing TextTo replace text, launch the Replace Text
dialog using the EditReplace... command or the
&Ctrl;R shortcut,
enter a search string and optionally a replace string, set
the options as desired and
hit the Replace button. If the replace
string is empty, each match will be removed.If you are using a regular expression to find the text to replace, you can
employ placeholders to reuse text
captured in parenthesized subpatterns of the expression.You can do find, replace and
ifind (incremental search) from the editor
command line.Finding text in multiple filesTo search for text in multiple files at once, please refer to the
Find in Files Panel section.Using BookmarksThe 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:Move the insertion cursor to the line and activate the
BookmarksSet
Bookmark (&Ctrl;B) command.Click on the Icon Border Pane next to the 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.To quickly move between bookmarks or to the next/previous bookmark,
use the BookmarksNext (AltPage Down) or BookmarksPrevious
(AltPage Up) commands.To remove a single bookmark, move the insertion cursor to the line
of that bookmark and activate the BookmarksClear Bookmark (&Ctrl;B) command.To remove all bookmarks at once, use the BookmarksClear All Bookmarks menu entry.Wrapping textThere are two types of text wrapping:
Static word wrappingDynamic word wrappingStatic word wrappingThis 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
Enable static word wrap checkbox in the
Editing page of the configuration dialog.To set the maximum line length (maximum characters per line), use the
Wrap words at option in the
Editing page of the
configuration dialog.If enabled, static word wrapping 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 will be longer than the maximum line length, if they contain any whitespace allowing that.Dynamic word wrappingThis feature allows the text lines to be wrapped at the view border of the screen.
The wrapping only affects the view, no hard line break character is inserted in the text.To enable/disable it, check/uncheck the
Dynamic word wrap checkbox in the
Appearance page of the
configuration dialog.Using automatic indentationThe &kate; editor component supports several autoindenting modes,
designed for different text formats. You can pick from the available modes using
the ToolsIndentation
menu. The autoindent modules also provides a function
ToolsAlign
which will recalculate the indentation of the selected or current line. Thus,
you may reindent your entire document by selecting all the text and activating
that action.All the indent modes use the indentation related settings in the active
document.You can set all sorts of configuration variables, including
those related to indentation using Document
Variables and File
types.Available Autoindent ModesNoneSelecting this mode turns automatic indentation off entirely.NormalThis indenter simply keeps the indentation similar to the
previous line with any content other than whitespace. You can combine this
with using the indent and unindent actions for indenting to your own taste.
C StyleAn indenter for C and similar languages, such as
C++, C#, java, javascript and so on. This indenter will not work with scripting
languages such as Perl or PHP.Python StyleAn indenter specifically designed for the python scripting language.
XMLA very nice XML auto-indenter. However tempting, do not try to
use this with HTML other than XHTML, because it fails with the old style
HTML tags (open tags like for example <br>)S&S C StyleAn alternative indenter for C and similar languages, with the
same constraints.Variable Based Indenter
The variable based indenter is special in that it can be configured using variables in
the document or in a filetype configuration. The following variables are
read:
var-indent-indent-afterA regular expression which will cause a line to
be indented by one unit, if the first non-whitespace-only line above matches.var-indent-indentA regular expression, which will cause a matching line
to be indented by one unit if matching.var-indent-unindentA regular expression which will cause the line to be
unindented by one unit if matching.var-indent-triggercharsA list of characters that should cause the
indention to be recalculated immediately when typed.var-indent-handle-couplesA list of paranthesis sets to handle. Any combination
of 'paranthesis', 'braces' and 'brackets'. Each set type is handled in
the following way. If there are unmatched opening instances on the above line,
one indent unit is added. If there are unmatched closing instances on the
current line, one indent unit is removed.var-indent-couple-attributeWhen looking for unmatched couple openings/closings,
only characters with this attribute are considered. The value must be the
attribute name from the syntax xml file, for example "Symbol". If it is not
specified, attribute 0 is used (usually 'Normal Text').