<!--pulled in by kwrite too-->
<chapter id="kate-part">
<chapterinfo>
<authorgroup>
<author>&Anders.Lund; &Anders.Lund.mail;</author>
<author>&Dominik.Haumann; &Dominik.Haumann.mail;</author>
<!-- TRANS:ROLES_OF_TRANSLATORS -->
</authorgroup>
</chapterinfo>
<title>Working with the &kappname; editor</title>

<sect1 id="kate-part-overview">

<title>Overview</title>

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

<para>The editor is composed of the following components:</para>

<variablelist>

<varlistentry>
<term>The editing area</term>
<listitem><para>This is where the text of your document is located.</para></listitem>
</varlistentry>

<varlistentry>
<term>The Scrollbars</term>
<listitem>
<para>The scrollbars 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.</para>
<para>The scrollbars are displayed and hidden as required.</para>
</listitem>
</varlistentry>

<varlistentry>
<term>The Icon Border</term>
<listitem>
<para>The icon border is a small pane on the left side of the editor,
displaying a small icon next to marked lines.</para>
<para>You can set or remove a <link
linkend="kate-part-bookmarks">bookmark</link> in a visible line by
clicking the &LMB; in the icon border next to that line.</para>
<para>The display of the icon border can be toggled using the
<menuchoice><guimenu>View</guimenu> <guimenuitem>Show Icon
Border</guimenuitem></menuchoice> menu item.</para>
</listitem>
</varlistentry>

<varlistentry>
<term>The Line Numbers Pane</term>
<listitem>
<para>The Line numbers pane shows the line numbers of all visible
lines in the document.</para>
<para>The display of the Line Numbers Pane can be toggled using the
<menuchoice><guimenu>View</guimenu> <guimenuitem>Show Line
Numbers</guimenuitem></menuchoice> menu item.</para>
</listitem>
</varlistentry>

<varlistentry>
<term>The Folding Pane</term>
<listitem>
<para>The folding pane allows you to collapse or expand foldable blocks
of lines. The calculation of the foldable regions is done according to
rules in the syntax highlight definition for the document.</para>
</listitem>
</varlistentry>

</variablelist>

<itemizedlist>
<title>Also in this Chapter:</title>
<listitem><para><link linkend="kate-part-navigation">Navigating in the
Text</link> </para></listitem>
<listitem><para><link linkend="kate-part-selection">Working with the
Selection</link></para></listitem>
<listitem><para><link linkend="kate-part-copy-and-paste">Copying and
Pasting Text</link></para></listitem>
<listitem><para><link linkend="kate-part-find-replace">Finding and
Replacing Text</link></para></listitem>
<listitem><para><link linkend="kate-part-bookmarks">Using
Bookmarks</link></para></listitem>
<listitem><para><link linkend="kate-part-auto-wrap">Automatically
Wrapping Text</link></para></listitem>
<listitem><para><link linkend="kate-part-autoindent">Using automatic indenting</link></para></listitem>
</itemizedlist>

</sect1>

<sect1 id="kate-part-navigation">
<title>Navigating in the Text</title>

<para>Moving around in the text in &kappname; is similar to most graphical text
editors. You move the cursor using the arrow keys and the
&PgUp;, &PgDn;, &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 has different
effects on different keys:
<itemizedlist>
<listitem><para>For the &Up; and &Down; keys it
means scroll rather than move the cursor.</para></listitem>
<listitem><para>For the &Left; and &Right;
keys it means skip words rather than characters.</para></listitem>
<listitem><para>For the &PgUp; and &PgDn;
keys it means move to the visible edge of the view rather than browse.</para>
</listitem>
<listitem><para>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.</para></listitem>
</itemizedlist>
</para>

<para>&kappname; also provides you with a way to quickly jump to a matching brace
or parenthesis: place the cursor on the inside of a parenthesis or brace
character, and press <keycombo action="simul">&Ctrl;<keycap>6</keycap></keycombo>
to jump to the matching parenthesis or brace.</para>

<para>In addition you can use
<link linkend="kate-part-bookmarks">bookmarks</link> to quickly jump to
positions that you define on your own.</para>

</sect1>

<sect1 id="kate-part-selection">
<title>Working with the Selection</title>

<para>There are two basic ways of selecting text in &kappname;: using the
mouse, and using the keyboard.</para>

<para>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.</para>

<para>Double-clicking a word will select that word.</para>

<para>Triple-clicking in a line will select the entire line.</para>

<para>If &Shift; is held down while clicking, text will be
selected:</para>

<itemizedlist>
<listitem><para>If nothing is already selected, from the text cursor
position to the mouse cursor position.</para></listitem>
<listitem><para>If there is a selection, from and including that
selection to the mouse cursor position.</para></listitem>
</itemizedlist>

<note>
<para>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.
</para>
</note>

<para>To select using the keyboard, hold down the &Shift; key while
using the navigation keys (Arrow keys, &PgUp;, &PgDn;, &Home; and
&End;, possibly in combination with &Ctrl; to extend
the move of the text cursor).</para>

<para>See also the section <link
linkend="kate-part-navigation">Navigating in the Text</link> in this
chapter.</para>

<para>To <action>Copy</action> the current selection, use the
<menuchoice><guimenu>Edit</guimenu>
<guimenuitem>Copy</guimenuitem></menuchoice> menu item or the keyboard
shortcut (defaults to <keycombo
action="simul">&Ctrl;<keycap>C</keycap></keycombo>).</para>

<para>To <action>Deselect</action> the current selection, use the
<menuchoice><guimenu>Edit</guimenu>
<guimenuitem>Deselect</guimenuitem></menuchoice> menu item, or the
keyboard shortcut (default is <keycombo
action="simul">&Ctrl;&Shift;<keycap>A</keycap></keycombo>), or click
with the &LMB; in the editor.</para>

<sect2 id="kate-part-selection-block">
<title>Using Block Selection</title>

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

<para>Block Selection can be toggled using the
<menuchoice><guimenu>Edit</guimenu> <guimenuitem>Block
Selection Mode</guimenuitem></menuchoice> menu item. The default keyboard
shortcut is <keycombo action="simul">&Ctrl;&Shift;<keycap>B</keycap>
</keycombo>.</para>

</sect2>

<sect2 id="kate-part-selection-overwrite">
<!-- term not used in settings Editing Text Seöection Mode, it is called "Normal"-->
<title>Using Overwrite Selection</title>

<para>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.</para>

<para>Overwrite Selection is enabled by default.</para>

<para>To change the setting for this option, use the <link
linkend="pref-edit-cursor-selection">Cursor &amp; Selection</link> page of the <link
linkend="config-dialog">Configuration Dialog</link>.</para>

</sect2>

<sect2 id="kate-part-selection-persistent">

<title>Using Persistent Selection</title>

<para>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.</para>

<para>Persistent Selection is disabled by default.</para>

<para>Persistent Selection can be enabled in the <link
linkend="pref-edit-cursor-selection">Cursor &amp; Selection</link> page of the <link
linkend="config-dialog">Configuration Dialog</link>.</para>

<warning> <!-- is that still possible in 4.4? radio button Normal + Persistent!-->
<para>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.</para>
</warning>

</sect2>

</sect1>

<sect1 id="kate-part-copy-and-paste">

<title>Copying and Pasting Text</title>

<para>To copy text, select it and use the
<menuchoice><guimenu>Edit</guimenu>
<guimenuitem>Copy</guimenuitem></menuchoice> menu item. Additionally,
selecting text with the mouse will cause selected text to be copied to
the X selection.</para>

<para>To paste the text currently in the clipboard, use the
<menuchoice>
<guimenu>Edit</guimenu><guimenuitem>Paste</guimenuitem></menuchoice>
menu item.</para>

<para>Additionally, text selected with the mouse may be pasted by
clicking the &MMB; at the desired position.</para>

<tip>
<para>If you are using the &kde; desktop, you can retrieve earlier
copied text from any application using the &klipper; icon in the
system tray.</para>
</tip>

</sect1>

<!-- changed in 4.5-->
<sect1 id="kate-part-find-replace">
<title>Finding and Replacing Text</title>

<sect2 id="find-replace-bars">
<title>The Search and Replace Bars</title>


<para>&kappname; has an incremental search bar and a power search and
replace bar, which  offers the means of entering a
replacement string along with a few extra options.</para>

<para>The bars offer the following common options:</para>

<variablelist>

<varlistentry>
<term><guilabel>Find</guilabel></term>
<listitem><para>This is where to enter the search string. The interpretation of the string
depends on some of the options described below.</para></listitem>
</varlistentry>

<varlistentry>
<term><guilabel>Match case</guilabel></term>
<listitem>
<para>If enabled, the search will be limited to entries that match the
case (upper or lower) of each of the characters in the search pattern.</para>
</listitem>
</varlistentry>

</variablelist>

<para>The power search and replace bar offers some
additional options:</para>

<variablelist>

<varlistentry>
<term><guilabel>Plain Text</guilabel></term>
<listitem>
<para>Literally match any occurrence of the search string.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><guilabel>Whole Words</guilabel></term>
<listitem>
<para>If selected, 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.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><guilabel>Escape Sequences</guilabel></term>
<listitem>
<para>If selected, the <guibutton>Add</guibutton> menuitem at the
bottom of the context menu of the text boxes will be enabled
and allows you to add escape sequences to the
search pattern from a predefined list.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><guilabel>Regular Expression</guilabel></term>
<listitem>
<para>If selected, the search string is interpreted as a regular
expression. The <guibutton>Add</guibutton> menuitem at the
bottom of the context menu of the text boxes will be enabled
and allows you to add regular expression items to the
search pattern from a predefined list.</para>
<para>See <link linkend="regular-expressions">Regular
Expressions</link> for more on these.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><guilabel>Search in the selection only</guilabel></term>
<listitem>
<para>If checked, the search and replace will be performed within
the selected text only.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><guilabel>Find all</guilabel></term>
<listitem>
<para>Clicking this button highlights
all matches in the document and shows the number of found matches in a small popup.
</para></listitem>
</varlistentry>

</variablelist>

</sect2>
<!--FIXME keep in sync with kate/menus.docbook <varlistentry id="edit-find"> -->
<sect2 id="finding-text">
<title>Finding Text</title>

<para>To find text, launch the incremental search bar
with <keycombo action="simul">&Ctrl;<keycap>F</keycap></keycombo> or
from the <menuchoice><guimenu>Edit</guimenu>
<guimenuitem>Find...</guimenuitem></menuchoice> menu item.</para>
<para>This opens the incremental search bar at the bottom of the editor window.
On the left side of the bar is a button with an icon to close the bar, followed by a small text 
box for entering the search pattern.</para>
<para>When you start entering the characters of your search pattern, the search starts
immediately. If there is a match in the text this is highlighted and the background color
of the entry field changes to light green. If the search pattern does not match any
string in the text, this is indicated by a light red background color of the entry field.</para>
<para>Use the 
<inlinemediaobject><imageobject><imagedata fileref="arrow-up-double-22.png" format="PNG"/></imageobject></inlinemediaobject> or
<inlinemediaobject><imageobject><imagedata fileref="arrow-down-double-22.png" format="PNG"/></imageobject></inlinemediaobject> button
to jump to the next or previous match in the document.</para>
<para>Matches in the document are highlighted even when you close the search bar. To clear
this highlighting, press the &Esc; key.</para>
<para>You can choose whether the search should be case sensitive.
Selecting <inlinemediaobject><imageobject><imagedata fileref="format-text-superscript-22.png" format="PNG"/></imageobject></inlinemediaobject>
will limit finds to entries that match the
case (upper or lower) of each of the characters in the search  pattern.</para>
<para>Click on the <inlinemediaobject><imageobject><imagedata fileref="configure-shortcuts-22.png" format="PNG"/></imageobject></inlinemediaobject>
button at the right side of the incremental search bar to
switch to the power search and replace bar.
</para>
<para>
To repeat the last find operation, if any, without calling the incremental
search bar, use <menuchoice>
<shortcut><keycombo action="simul"><keycap>F3</keycap></keycombo></shortcut>
<guimenu>Edit</guimenu><guimenuitem>Find Next</guimenuitem></menuchoice>
or
<menuchoice><shortcut>
<keycombo action="simul">&Shift;<keycap>F3</keycap></keycombo></shortcut>
<guimenu>Edit</guimenu><guimenuitem>Find Previous</guimenuitem></menuchoice>.
</para>

</sect2>
<!--FIXME keep in sync with kate/menus.docbook <varlistentry id="edit-replace"> -->
<sect2 id="replacing-text">
<title>Replacing Text</title>

<para>To replace text, launch the power search and replace bar
using the <menuchoice><guimenu>Edit</guimenu>
<guimenuitem>Replace</guimenuitem></menuchoice> command, or the
<keycombo action="simul">&Ctrl;<keycap>R</keycap></keycombo> shortcut.</para>
<para>On the upper left side of the bar is a button with an icon to close the bar, followed by a small text
box for entering the search pattern.</para>
<para>You can control the search mode by selecting the options <guilabel>Plain Text</guilabel>,
<guilabel>Whole Words</guilabel>, <guilabel>Escape Sequences</guilabel> or
<guilabel>Regular Expression</guilabel> from the drop down box.
</para>
<para>If <guilabel>Escape sequences</guilabel> or <guilabel>Regular expression</guilabel> are
selected, the <guibutton>Add...</guibutton> menuitem at the bottom of the context menu of the text boxes will be enabled
and allows you to add escape sequences or regular expression items to the
search or replace pattern from predefined lists.</para>
<para>Use the
<inlinemediaobject><imageobject><imagedata fileref="arrow-up-double-22.png" format="PNG"/></imageobject></inlinemediaobject> or
<inlinemediaobject><imageobject><imagedata fileref="arrow-down-double-22.png" format="PNG"/></imageobject></inlinemediaobject> button
to jump to the next or previous match in the document.</para>
<para>Enter the text to replace with in the text box labeled <guilabel>Replace</guilabel>
and click the <guibutton>Replace</guibutton> button to replace only the highlighted text or
the <guibutton>Replace All</guibutton> button to replace the search text in the whole document.
</para>
<para>You can modify the search and replace behavior by selecting different
options at the bottom of the bar.
Selecting <inlinemediaobject><imageobject><imagedata fileref="format-text-superscript-22.png" format="PNG"/></imageobject></inlinemediaobject>
will limit finds to entries that match the
case (upper or lower) of each of the characters in the search  pattern.
<inlinemediaobject><imageobject><imagedata fileref="edit-select-all-22.png" format="PNG"/></imageobject></inlinemediaobject>
will search and replace within the current selection only.
The <guilabel>Find All</guilabel> button highlights
all matches in the document and shows the number of found matches in a small popup.
</para>
<para>Click on the <inlinemediaobject><imageobject><imagedata fileref="configure-shortcuts-22.png" format="PNG"/></imageobject></inlinemediaobject>
button at the right side of the power search and replace bar to
switch to the incremental search bar.
</para>
<tip>
<para>If you are using a regular expression to find the text to replace, you can
employ backreferences to reuse text captured in parenthesized subpatterns of the expression.</para>
<para>See <link linkend="regular-expressions">Regular Expressions</link> for more
on those.</para>
</tip>

<tip><para>You can do <command>find</command>, <command>replace</command> and
<command>ifind</command> (incremental search) from the
<link linkend="advanced-editing-tools-commandline">command line</link>.</para>
</tip>

</sect2>

</sect1>

<sect1 id="kate-part-bookmarks">
<title>Using Bookmarks</title>

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

<para>You can set or remove a bookmark in a line in two ways:</para>

<itemizedlist>
<listitem>
<para>Move the insertion cursor to the line and activate the
<menuchoice><guimenu>Bookmarks</guimenu><guimenuitem>Set
Bookmark</guimenuitem></menuchoice> (<keycombo
action="simul">&Ctrl;<keycap>B</keycap></keycombo>) command.</para>
</listitem>
<listitem>
<para>Click in the Icon Border next to the line.</para>
</listitem>
</itemizedlist>


<para>Bookmarks are available in the <guimenu>Bookmarks</guimenu>
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.</para>

<para>To quickly move between bookmarks or to the next/previous bookmark,
use the <menuchoice><guimenu>Bookmarks</guimenu><guimenuitem>Next</guimenuitem>
</menuchoice> (<keycombo action="simul">&Alt;&PgDn;</keycombo>) or <menuchoice>
<guimenu>Bookmarks</guimenu><guimenuitem>Previous</guimenuitem></menuchoice>
(<keycombo action="simul">&Alt;&PgUp;</keycombo>) commands.</para>

</sect1>

<sect1 id="kate-part-auto-wrap">
<!--dynamic word wrap needs description here-->
<title>Automatically Wrapping text</title>

<para>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.</para>

<para>To enable/disable it, check/uncheck the <guibutton>Static Word Wrap</guibutton> checkbox in the
<link linkend="pref-word-wrap">edit page</link> of the <link linkend="config-dialog">configuration dialog</link>.</para>

<para>To set the maximum line width (maximum characters per line), use the
<link linkend="pref-wrap-words-at"><guibutton>Wrap Words At</guibutton></link>
option in the <link linkend="pref-edit">Editing</link> page of the <link linkend="config-dialog">configuration
dialog</link>.</para>

<para>If enabled,
it has the following effects:

<itemizedlist>
<listitem><para>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.</para></listitem>
<listitem><para>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.</para></listitem>
</itemizedlist>

</para>

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

</sect1>

<sect1 id="kate-part-autoindent">
<title>Using automatic indenting</title>

<para>&kappname;s editor component supports a variety of autoindenting modes,
designed for different text formats. You can pick from the available modes using
the <menuchoice><guimenu>Tools</guimenu><guisubmenu>Indentation</guisubmenu></menuchoice>
menu. The autoindent modules also provide a function
<menuchoice><guimenu>Tools</guimenu><guimenuitem>Align</guimenuitem></menuchoice>
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.</para>

<para>All the indent modes use the indentation related settings in the active
document.</para>

<tip><para>You can set all sorts of configuration variables, including
those related to indentation using
<link linkend="config-variables">Document Variables</link> and
<link linkend="pref-open-save-modes-filetypes">File types</link>.</para></tip>

<variablelist>

<title>Available Autoindent Modes</title>

<varlistentry>
<term>None</term>
<listitem><para>Selecting this mode turns automatic indenting off entirely.</para>
</listitem>
</varlistentry>

<varlistentry>
<term>Normal</term>
<listitem><para>This 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.
</para></listitem>
</varlistentry>

<varlistentry><term>C Style</term>
<listitem><para>An 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.</para></listitem>
</varlistentry>

<varlistentry>
<term>Haskell</term>
<listitem><para>An indenter for the functional programming language Haskell.
</para></listitem>
</varlistentry>

<varlistentry>
<term>Lilypond</term>
<listitem><para>An indenter for the Lilypond notation language for music.
</para></listitem>
</varlistentry>

<varlistentry>
<term>Lisp</term>
<listitem><para>An indenter specifically for the Lisp scripting language and
Lisp dialects.
</para></listitem>
</varlistentry>

<varlistentry>
<term>Python</term>
<listitem><para>An indenter specifically for the python scripting language.
</para></listitem>
</varlistentry>

<varlistentry>
<term>XML Style</term>
<listitem><para>An indenter specifically for XML like languages.
</para></listitem>
</varlistentry>
<!--Ruby + Lua missing -->
</variablelist>

</sect1>

<sect1 id="kate-part-line-modification">
<title>Line Modification Indicators</title>

<para>&kappname;'s line modification indicators let you easily see what you have
recently changed in a file.  By default, saved changes are indicated by a green
bar to the left of a document, while unsaved changes are indicated by an orange
bar.</para>

<para>
<mediaobject>
<imageobject><imagedata format="PNG" fileref="line-modification-system.png"/></imageobject>
<caption><para>Line Modification Indicators in action.</para></caption>
</mediaobject>
</para>

<para>You can change the colors used in the
<link linkend="prefcolors"><guilabel>Fonts &amp; Colors</guilabel> configuration
panel</link>, or you can disable this feature completely in the
<link linkend="appearance-borders"><guilabel>Borders</guilabel> tab of the
<guilabel>Appearance</guilabel> configuration panel</link>.</para>

</sect1>

<sect1 id="kate-part-scrollbar-minimap">
<title>The Scrollbar Minimap</title>

<para>&kappname;'s Scrollbar Minimap displays a preview of documents in place of
the scrollbar.  The currently visible portion of the document is highlighted.
</para>

<para>
<mediaobject>
<imageobject><imagedata format="PNG" fileref="minimap.png"/></imageobject>
<caption><para>The Scrollbar Minimap shows a preview of the &kate; source code.
</para></caption>
</mediaobject>
</para>

<para>You can temporarily enable or disable the minimap by selecting
<menuchoice><guimenu>View</guimenu><guimenuitem>View Scrollbar Minimap</guimenuitem></menuchoice>
or permanently in <link linkend="appearance-borders">the Appearance section of
&kappname;'s configuration</link>.</para>

</sect1>

</chapter>
