1
<chapter id="advanced-editing-tools">
4
<author>&Anders.Lund; &Anders.Lund.mail;</author>
5
<author>&Dominik.Haumann; &Dominik.Haumann.mail;</author>
6
<!-- TRANS:ROLES_OF_TRANSLATORS -->
9
<title>Advanced Editing Tools</title>
11
<sect1 id="advanced-editing-tools-comment">
13
<title>Comment/Uncomment</title>
15
<para>The <guimenuitem>Comment</guimenuitem> and <guimenuitem>Uncomment</guimenuitem> commands, available from the
16
<guimenu>Tools</guimenu> menu allow you to add or remove comment
17
markers to the selection, or the current line if no text is selected,
18
if comments are supported by the format of the text you are
21
<para>The rules for how commenting is done are defined in the syntax
22
definitions, so if syntax highlighting is not used, commenting/uncommenting
23
is not possible. </para>
25
<para>Some formats define single line comment markers, some multiline
26
markers and some both. If multiline markers are not available,
27
commenting out a selection that does not fully include its last line
28
is not possible.</para>
30
<para>If a single line marker is available, commenting single lines is
31
preferred where applicable, as this helps to avoid problems with
32
nested comments.</para>
34
<para>When removing comment markers, no uncommented text should be
35
selected. When removing multiline comment markers from a selection,
36
any whitespace outside the comment markers is ignored.</para>
38
<para><indexterm><primary>comment</primary></indexterm>
39
To place comment markers, use the
40
<menuchoice><guimenu>Tools</guimenu><guimenuitem>Comment</guimenuitem></menuchoice>
41
menu item or the related keyboard shortcut sequence, the default is
42
<keycombo action="simul">&Ctrl;<keycap>D</keycap></keycombo>.</para>
44
<para><indexterm><primary>uncomment</primary></indexterm>
45
To remove comment markers, use the
46
<menuchoice><guimenu>Tools</guimenu><guimenuitem>Uncomment</guimenuitem></menuchoice>
47
menu item or the related keyboard shortcut, the default is <keycombo
48
action="simul">&Ctrl;&Shift;<keycap>D</keycap></keycombo>.</para>
52
<sect1 id="advanced-editing-tools-commandline">
53
<title>The Editor Component Command Line</title>
55
<para>&kappname;'s editor component has an internal command line, allowing you to
56
perform various actions from a minimal GUI. The command line is a text entry
57
at the bottom of the editor area; to show it select
58
<menuchoice><guimenu>View</guimenu><guimenuitem>Switch to Command Line</guimenuitem></menuchoice>
59
or use the shortcut (default is
60
<keycombo action="simul"><keycap>F7</keycap></keycombo>). The editor provides
61
a set of commands as documented below, and additional commands can be provided
64
<para>To execute a command, type the command then press the return key. The
65
command line will indicate whether it succeeded and possibly display a message. If
66
you entered the command line by pressing <keycap>F7</keycap> it will
67
automatically hide after a few seconds. To clear the message and enter a new
68
command, press <keycap>F7</keycap> again.</para>
70
<para>The command line has a built-in help system; issue the command
71
<command>help</command> to get started. To see a list of all available commands
72
issue <command>help list</command>; to view help for a specific command, do
73
<command>help <replaceable>command</replaceable></command>.</para>
75
<para>The command line has a built in history, so you can reuse commands already
76
typed. To navigate the history, use the <keycap>Up</keycap> and
77
<keycap>Down</keycap> keys. When showing historical commands, the argument part
78
of the command will be selected, allowing you to easily overwrite the
81
<sect2 id="advanced-editing-tools-commandline-commands">
82
<title>Standard Command Line Commands</title>
85
<title>Argument types</title>
89
<listitem><para>This is used with commands that turns things on or off.
90
Legal values are <userinput>on</userinput>, <userinput>off</userinput>,
91
<userinput>true</userinput>, <userinput>false</userinput>,
92
<userinput>1</userinput> or <userinput>0</userinput>.</para></listitem>
97
<listitem><para>An integer number.</para></listitem>
102
<listitem><para>A string, surrounded by single quotes (') or double quotes (") when it contains spaces.</para></listitem>
109
<sect3 id="advanced-editing-tools-commandline-commands-configure">
110
<title>Commands for Configuring the Editor</title>
112
<para>These commands are provided by the editor component, and allow you to
113
configure the active document and view only. This is handy if you want to use
114
a setting different from the default settings, for example for indentation.
120
<term><cmdsynopsis><command>set-tab-width</command><arg choice="req">INTEGER width</arg></cmdsynopsis></term>
121
<listitem><para>Sets the tab width to the number <userinput>width</userinput>.</para></listitem>
125
<term><cmdsynopsis><command>set-indent-width</command><arg choice="req">INTEGER width</arg></cmdsynopsis></term>
126
<listitem><para>Sets the indentation width to the number
127
<userinput>width</userinput>. Used only if you are indenting with
128
spaces.</para></listitem>
132
<term><cmdsynopsis><command>set-word-wrap-column</command><arg choice="req">INTEGER width</arg></cmdsynopsis></term>
133
<listitem><para>Sets the line width for hard wrapping to
134
<userinput>width</userinput>. This is used if you are having your text wrapped
135
automatically.</para></listitem>
139
<term><cmdsynopsis><command>set-icon-border</command><arg choice="req">BOOLEAN enable</arg>
140
</cmdsynopsis></term>
141
<listitem><para>Sets the visibility of the icon border.</para></listitem>
145
<term><cmdsynopsis><command>set-folding-markers</command><arg choice="req">BOOLEAN enable</arg></cmdsynopsis></term>
146
<listitem><para>Sets the visibility of the folding markers pane.</para></listitem>
150
<term><cmdsynopsis><command>set-line-numbers</command><arg choice="req">BOOLEAN enable</arg></cmdsynopsis></term>
151
<listitem><para>Sets the visibility of the line numbers pane.</para></listitem>
155
<term><cmdsynopsis><command>set-replace-tabs</command><arg choice="req">BOOLEAN enable</arg></cmdsynopsis></term>
156
<listitem><para>If enabled, tabs are replaced with spaces as you type.
161
<term><cmdsynopsis><command>set-remove-trailing-space</command><arg choice="req">BOOLEAN enable</arg></cmdsynopsis></term>
162
<listitem><para>If enabled, trailing whitespace is removed whenever the cursor
163
leaves a line.</para></listitem>
167
<term><cmdsynopsis><command>set-show-tabs</command><arg choice="req">BOOLEAN enable</arg></cmdsynopsis></term>
168
<listitem><para>If enabled, TAB characters and trailing whitespace will be
169
visualized by a small dot.</para></listitem>
173
<term><cmdsynopsis><command>set-show-indent</command><arg choice="req">BOOLEAN enable</arg></cmdsynopsis></term>
174
<listitem><para>If enabled, indentation will be visualized by a vertical dotted
175
line.</para></listitem>
179
<term><cmdsynopsis><command>set-indent-spaces</command><arg choice="req">BOOLEAN enable</arg></cmdsynopsis></term>
180
<listitem><para>If enabled, the editor will indent with
181
<option>indent-width</option> spaces for each indentation level, rather than
182
with one TAB character.</para></listitem>
186
<term><cmdsynopsis><command>set-mixed-indent</command><arg choice="req">BOOLEAN enable</arg></cmdsynopsis></term>
187
<listitem><para>If enabled, &kappname; will use a mix of TAB and spaces for
188
indentation. Each indentation level will be <option>indent-width</option> wide,
189
and more indentation levels will be optimized to use as many TAB characters as
191
<para>When executed, this command will additionally set space indentation enabled,
192
and if the indent width is unspecified it will be set to half of the
193
<option>tab-width</option> for the document at the time of execution.</para></listitem>
197
<term><cmdsynopsis><command>set-word-wrap</command><arg choice="req">BOOLEAN
198
enable</arg></cmdsynopsis></term>
199
<listitem><para>Enables dynamic word wrap according to
200
<userinput>enable</userinput>.</para></listitem>
204
<term><cmdsynopsis><command>set-replace-tabs-save</command><arg choice="req">BOOLEAN enable
205
</arg></cmdsynopsis></term>
206
<listitem><para>When enabled, tabs will be replaced with whitespace whenever
207
the document is saved.</para></listitem>
211
<term><cmdsynopsis><command>set-remove-trailing-space-save</command><arg choice="req">BOOLEAN enable</arg></cmdsynopsis></term>
212
<listitem><para>When enabled, trailing space will be removed from each line
213
whenever the document is saved.</para></listitem>
217
<term><cmdsynopsis><command>set-indent-mode</command><arg choice="req">STRING name</arg></cmdsynopsis></term>
218
<listitem><para>Sets the autoindentation mode to <userinput>name</userinput>.
219
If <userinput>name</userinput> is not known, the mode is set to 'none'. Valid
220
modes are 'none', 'normal', 'cstyle', 'haskell', 'lilypond', 'lisp', 'python',
221
'ruby' and 'xml'.</para></listitem>
225
<term><cmdsynopsis><command>set-auto-ident</command><arg choice="req">BOOLEAN script</arg></cmdsynopsis></term>
226
<listitem><para>Enable or disable autoindentation.</para></listitem>
230
<term><cmdsynopsis><command>set-highlight</command><arg choice="req">STRING highlight</arg></cmdsynopsis></term>
231
<listitem><para>Sets the syntax highlighting system for the document. The
232
argument must be a valid highlight name, as seen in the
233
<menuchoice><guimenu>Tools</guimenu><guisubmenu>Highlighting</guisubmenu></menuchoice>
234
menu. This command provides an autocompletion list for its
235
argument.</para></listitem>
239
<term><cmdsynopsis><command>reload-scripts</command></cmdsynopsis></term>
240
<listitem><para>Reload all <link linkend="dev-scripting">JavaScript
241
scripts</link> used by Kate, including indenters and command line scripts.</para></listitem>
245
<term><cmdsynopsis><command>set-mode</command><arg choice="req">STRING mode</arg></cmdsynopsis></term>
246
<listitem><para>Choose the filetype scheme for the current document.
251
<term><cmdsynopsis><command>nn[oremap]</command><arg choice="req">STRING original</arg>
252
<arg choice="req">STRING mapped</arg></cmdsynopsis></term>
253
<listitem><para>Map the key sequence <userinput>original</userinput> to
254
<userinput>mapped</userinput>.</para></listitem>
261
<sect3 id="advanced-editing-tools-commandline-commands-edit">
262
<title>Commands for editing</title>
264
<para>These commands modify the current document.</para>
268
<term><cmdsynopsis><command>indent</command></cmdsynopsis></term>
269
<listitem><para>Indents the selected lines or the current line.</para></listitem>
273
<term><cmdsynopsis><command>unindent</command></cmdsynopsis></term>
274
<listitem><para>Unindents the selected lines or current line.</para></listitem>
278
<term><cmdsynopsis><command>cleanindent</command></cmdsynopsis></term>
279
<listitem><para>Cleans up the indentation of the selected lines or current line
280
according to the indentation settings in the document.
285
<term><cmdsynopsis><command>comment</command></cmdsynopsis></term>
286
<listitem><para>Inserts comment markers to make the selection or selected lines
287
or current line a comment according to the text format as defined by the syntax
288
highlight definition for the document.</para></listitem>
292
<term><cmdsynopsis><command>uncomment</command></cmdsynopsis></term>
293
<listitem><para>Removes comment markers from the selection or selected lines
294
or current line according to the text format as defined by the syntax highlight
295
definition for the document.</para></listitem>
299
<term><cmdsynopsis><command>kill-line</command></cmdsynopsis></term>
300
<listitem><para>Deletes the current line.</para></listitem>
304
<term><cmdsynopsis><command>replace</command><arg choice="req"> STRING pattern</arg>
305
<arg choice="req">STRING replacement</arg></cmdsynopsis></term>
306
<listitem><para>Replaces text matching <userinput>pattern</userinput> with
307
<userinput>replacement</userinput>. If you want to include whitespace in the
308
<userinput>pattern</userinput>, you must quote both the <userinput>pattern</userinput>
309
and <userinput>replacement</userinput> with single or double quotes. If the
310
arguments are unquoted, the first word is used as <userinput>pattern</userinput>
311
and the rest for <userinput>replacement</userinput>. If
312
<userinput>replacement</userinput> is empty, each occurrence of
313
<userinput>pattern</userinput> is removed.</para>
314
<para>You can set flags to configure the search by adding a colon, followed
315
by one or more letters each representing a configuration, giving the form
316
<userinput>replace:options pattern replacement</userinput>. Available options
322
<term><userinput>b</userinput></term>
323
<listitem><para>Search backwards.</para></listitem>
327
<term><userinput>c</userinput></term>
328
<listitem><para>Search from cursor position.</para></listitem>
332
<term><userinput>e</userinput></term>
333
<listitem><para>Search in the selection only.</para></listitem>
337
<term><userinput>r</userinput></term>
338
<listitem><para>Do regular expression search. If set, you may use
339
<userinput>\N</userinput> where N is a number to represent captures in the
340
replacement string.</para></listitem>
344
<term><userinput>s</userinput></term>
345
<listitem><para>Do case sensitive search.</para></listitem>
349
<term><userinput>p</userinput></term>
350
<listitem><para>Prompt for permission to replace the next occurrence.</para></listitem>
354
<term><userinput>w</userinput></term>
355
<listitem><para>Match whole words only.</para></listitem>
365
<term><cmdsynopsis><command>date</command><arg choice="req">STRING format</arg></cmdsynopsis></term>
366
<listitem><para>Inserts a date/time string as defined by the specified
367
<userinput>format</userinput>, or the format <quote>yyyy-MM-dd hh:mm:ss</quote>
368
if none is specified. The following translations are done when interpreting
369
<userinput>format</userinput>:
374
<row><entry><literal>d</literal></entry><entry>The day as number without a leading zero (1-31).</entry></row>
375
<row><entry><literal>dd</literal></entry><entry>The day as number with a leading zero (01-31).</entry></row>
376
<row><entry><literal>ddd</literal></entry><entry>The abbreviated localized day name (e.g. 'Mon'..'Sun').</entry></row>
377
<row><entry><literal>dddd</literal></entry><entry>The long localized day name (e.g. 'Monday'..'Sunday').</entry></row>
378
<row><entry><literal>M</literal></entry><entry>The month as number without a leading zero (1-12).</entry></row>
379
<row><entry><literal>MM</literal></entry><entry>The month as number with a leading zero (01-12).</entry></row>
380
<row><entry><literal>MMMM</literal></entry><entry>The long localized month name (e.g. 'January'..'December').</entry></row>
381
<row><entry><literal>MMM</literal></entry><entry>The abbreviated localized month name (e.g. 'Jan'..'Dec').</entry></row>
382
<row><entry><literal>yy</literal></entry><entry>The year as two digit number
383
(00-99).</entry></row>
384
<row><entry><literal>yyyy</literal></entry><entry>The year as four digit number (1752-8000).</entry></row>
385
<row><entry><literal>h</literal></entry><entry>The hour without a leading zero (0..23 or 1..12 if AM/PM display).</entry></row>
386
<row><entry><literal>hh</literal></entry><entry>The hour with a leading zero (00..23 or 01..12 if AM/PM display).</entry></row>
387
<row><entry><literal>m</literal></entry><entry>The minute without a leading zero (0..59).</entry></row>
388
<row><entry><literal>mm</literal></entry><entry>The minute with a leading zero (00..59).</entry></row>
389
<row><entry><literal>s</literal></entry><entry>The second without a leading zero (0..59).</entry></row>
390
<row><entry><literal>ss</literal></entry><entry>The second with a leading zero (00..59).</entry></row>
391
<row><entry><literal>z</literal></entry><entry>The milliseconds without leading zeroes (0..999).</entry></row>
392
<row><entry><literal>zzz</literal></entry><entry>The milliseconds with leading zeroes (000..999).</entry></row>
393
<row><entry><literal>AP</literal></entry><entry>Use AM/PM display. AP will be replaced by either "AM" or "PM".</entry></row>
394
<row><entry><literal>ap</literal></entry><entry>Use am/pm display. ap will be replaced by either "am" or "pm".</entry></row>
403
<term><cmdsynopsis><command>char</command><arg choice="req">STRING identifier</arg></cmdsynopsis></term>
405
<para>This command allows you to insert literal characters by their
406
numerical identifier, in decimal, octal or hexadecimal form.
407
To use it launch the Editing Command dialog and type <userinput>char:
408
[number]</userinput> in the entry box, then hit
409
<guibutton>OK</guibutton>.</para>
412
<title><command>char</command> examples</title>
414
<para>Input: <userinput>char:234</userinput></para>
415
<para>Output: <computeroutput>ê</computeroutput></para>
416
<para>Input: <userinput>char:0x1234</userinput></para>
417
<para>Output: <computeroutput>ሴ</computeroutput></para>
425
<indexterm><primary>replace, sed style</primary>
426
<secondary>search, sed style</secondary></indexterm>
427
<command>s///[ig]</command> <command>%s///[ig]</command></term>
430
<para>This command does a sed-like search/replace operation on the
431
current line, or on the whole file (<command>%s///</command>).</para>
433
<para>In short, the text is searched for text matching the
434
<emphasis>search pattern</emphasis>, the regular expression between
435
the first and the second slash, and when a match is found, the
436
matching part of the text is replaced with the expression between the
437
second and last slash. Parentheses in the search pattern
438
create <emphasis>back references</emphasis>, that is the command
439
remembers which part of the string matched in the parentheses; these
440
strings can be reused in the replace pattern, referred to as
441
<userinput>\1</userinput> for the first set of parentheses,
442
<userinput>\2</userinput> for the second and so on.</para>
444
<para>To search for a literal <literal>(</literal> or
445
<literal>)</literal>, you need to <emphasis>escape</emphasis> it using
446
a backslash character: <userinput>\(\)</userinput></para>
448
<para>If you put an <userinput>i</userinput> at the end of the
449
expression, the matching will be case insensitive. If you put a
450
<userinput>g</userinput> at the end, all occurrences of the pattern will be
451
replaced, otherwise only the first occurrence is replaced.</para>
455
<title>Replacing text in the current line</title>
457
<para>Your friendly compiler just stopped, telling you that the class
458
<classname>myClass</classname> mentioned in line 3902 in your source file
459
is not defined.</para>
461
<para>"Buckle!" you think, it is of course
462
<classname>MyClass</classname>. You go to line 3902, and instead of trying
463
to find the word in the text, you launch the Editing Command Dialog,
464
enter <userinput>s/myclass/MyClass/i</userinput>, hit the
465
<guibutton>OK</guibutton> button, save the file and compile –
466
successfully without the error.</para>
471
<title>Replacing text in the whole file</title>
473
<para>Imagine that you have a file, in which you mention a <quote>Miss
474
Jensen</quote> several times, when someone comes in and tells you that
475
she just got married to <quote>Mr Jones</quote>. You want, of course,
476
to replace each and every occurrence of <quote>Miss Jensen</quote>
477
with <quote>Ms Jones</quote>.</para>
479
<para>Enter the command line and issue the command
480
<userinput>%s/Miss Jensen/Ms Jones/</userinput> and hit return, you
486
<title>A More Advanced Example</title>
488
<para>This example makes use of <emphasis>back references</emphasis>
489
as well as a <emphasis>character class</emphasis> (if you do not know what
490
that is, please refer to the related documentation mentioned
493
<para>Suppose you have the following line:
495
<programlisting>void MyClass::DoStringOps( String &foo, String &bar, String *p, int &a, int &b )</programlisting>
497
<para>Now you realize that this is not nice code, and decide that you
498
want to use the <constant>const</constant> keyword for all
499
<quote>address of</quote> arguments, those characterized by the &
500
operator in front of the argument name. You would also like to
501
simplify the white space, so that there is only 1 whitespace character
502
between each word.</para>
504
<para>Launch the Editing Command Dialog, and enter:
505
<userinput>s/\s+(\w+)\s+(&)/ const \1 \2/g</userinput> and hit the
506
<guibutton>OK</guibutton> button. The <userinput>g</userinput> at the end of the expression makes
507
the regular expression recompile for each match to save the <emphasis>backreferences</emphasis>.</para>
511
<computeroutput>void MyClass::DoStringOps( const String &foo, const String &bar, String *p, const int &a, const int &b )</computeroutput></para>
513
<para>Mission completed! Now, what happened? Well, we looked for some
514
white space (<literal>\s+</literal>) followed by one or more
515
alphabetic characters (<literal>\w+</literal>) followed by some more
516
whitespace (<literal>\s+</literal>) followed by an ampersand, and in
517
the process saved the alphabetic chunk and the ampersand for reuse in
518
the replace operation. Then we replaced the matching part of our line
519
with one whitespace followed by <quote>const</quote> followed by one
520
whitespace followed by our saved alphabetical chunk
521
(<literal>\1</literal>) followed by one whitespace followed by our
522
saved ampersand (<literal>\2</literal>)</para>
524
<para>Now in some cases the alphabetical chunk was
525
<quote>String</quote>, in some <quote>int</quote>, so using the
526
character class <literal>\w</literal> and the <literal>+</literal>
527
quantifier proved a valuable asset.</para>
536
<term><cmdsynopsis><command>sort</command></cmdsynopsis></term>
537
<listitem><para>Sorts the selected text or entire document.</para></listitem>
541
<term><cmdsynopsis><command>natsort</command></cmdsynopsis></term>
542
<listitem><para>Sort the selected lines or entire document naturally.</para>
545
<title><command>sort</command> vs. <command>natsort</command></title>
546
<para><userinput><command>sort</command>(a10, a1, a2)</userinput> results in
547
<computeroutput>a1, a10, a2</computeroutput></para>
548
<para><userinput><command>natsort</command>(a10, a1, a2)</userinput> results in
549
<computeroutput>a1, a2, a10</computeroutput></para>
550
</example></listitem>
554
<term><cmdsynopsis><command>moveLinesDown</command></cmdsynopsis></term>
555
<listitem><para>Move selected lines down.</para></listitem>
559
<term><cmdsynopsis><command>moveLinesUp</command></cmdsynopsis></term>
560
<listitem><para>Move selected lines up.</para></listitem>
564
<term><cmdsynopsis><command>uniq</command></cmdsynopsis></term>
565
<listitem><para>Remove duplicated lines from the selected text or the whole
566
document.</para></listitem>
570
<term><cmdsynopsis><command>rtrim</command></cmdsynopsis></term>
571
<listitem><para>Remove trailing space from the selected text or the whole
572
document.</para></listitem>
576
<term><cmdsynopsis><command>ltrim</command></cmdsynopsis></term>
577
<listitem><para>Remove leading space from the selected text or the whole
578
document.</para></listitem>
582
<term><cmdsynopsis><command>join</command><arg choice="opt">STRING separator</arg></cmdsynopsis></term>
583
<listitem><para>Join selected lines or whole document. Optionally takes a parameter
584
defining a separator, for example: <userinput><command>join</command> ', '</userinput>
589
<term><cmdsynopsis><command>rmblank</command></cmdsynopsis></term>
590
<listitem><para>Remove all blank spaces from the selected text or the whole
591
document.</para></listitem>
595
<term><cmdsynopsis><command>unwrap</command></cmdsynopsis></term>
596
<listitem><para>Unwrap the selected text or the whole document.</para></listitem>
600
<term><cmdsynopsis><command>each</command><arg choice="req">STRING script</arg></cmdsynopsis></term>
601
<listitem><para>Given a JavaScript function as an argument, call that for the list of
602
selected lines and replace them with the return value of that callback.</para>
605
<title>Join selected lines</title>
606
<para><userinput><command>each</command> 'function(lines){return lines.join(", ")}'
609
<para>Or, more briefly:</para>
610
<para><userinput><command>each</command> 'lines.join(", ")'</userinput></para>
619
<term><cmdsynopsis><command>filter</command><arg choice="req">STRING script</arg></cmdsynopsis></term>
620
<listitem><para>Given a JavaScript function as an argument, call that for the list of
621
selected lines and remove those where the callback returns false.</para>
624
<title>Remove blank lines</title>
625
<para><userinput><command>filter</command> 'function(1){return 1.length > 0;}'
628
<para>Or, more briefly:</para>
629
<para><userinput><command>filter</command> 'line.length > 0'</userinput></para>
636
<term><cmdsynopsis><command>map</command><arg choice="req">STRING script</arg></cmdsynopsis></term>
637
<listitem><para>Given a JavaScript function as an argument, call that for the list of
638
selected lines and replace the line with the value of the callback.</para>
641
<title>Remove blank lines</title>
642
<para><userinput><command>map</command> 'function(line){return
643
line.replace(/^s+/,"");}'
646
<para>Or, more briefly:</para>
647
<para><userinput><command>map</command> 'line.replace(/^s+/,"")'</userinput></para>
654
<term><cmdsynopsis><command>duplicateLinesUp</command></cmdsynopsis></term>
655
<listitem><para>Duplicate the selected lines above the current selection.</para>
660
<term><cmdsynopsis><command>duplicateLinesDown</command></cmdsynopsis></term>
661
<listitem><para>Duplicate the selected lines below the current selection.</para>
669
<sect3 id="advanced-editing-tools-commandline-commands-navigation">
670
<title>Commands for navigation</title>
675
<term><cmdsynopsis><command>goto</command><arg choice="req">INT line</arg></cmdsynopsis></term>
676
<listitem><para>This command navigates to the specified line.</para></listitem>
680
<term><cmdsynopsis><command>grep</command> <arg choice="req">STRING pattern</arg>
681
</cmdsynopsis></term>
682
<listitem><para>Search the document for the regular expression
683
<userinput>pattern</userinput>. For more information, see
684
<xref linkend="regular-expressions" /></para>
689
<term><cmdsynopsis><command>find</command><arg choice="req">STRING pattern</arg></cmdsynopsis></term>
690
<listitem><para>This command navigates to the first occurrence of
691
<userinput>pattern</userinput> according to the configuration. Following
692
occurrences can be found using
693
<menuchoice><guimenu>Edit</guimenu><guimenuitem>Find Next</guimenuitem></menuchoice>
694
(the default shortcut is <keycap>F3</keycap>).</para>
695
<para>The find command can be configured by appending a colon followed by one or
696
more options, the form is
697
<userinput>find:options pattern</userinput>. The
698
following options are supported:</para>
703
<term><userinput>b</userinput></term>
704
<listitem><para>Search backwards.</para></listitem>
708
<term><userinput>c</userinput></term>
709
<listitem><para>Search from cursor position.</para></listitem>
713
<term><userinput>e</userinput></term>
714
<listitem><para>Search in the selection only.</para></listitem>
718
<term><userinput>r</userinput></term>
719
<listitem><para>Do regular expression search. If set, you may use
720
<userinput>\N</userinput> where N is a number to represent captures in the
721
replacement string.</para></listitem>
725
<term><userinput>s</userinput></term>
726
<listitem><para>Do case sensitive search.</para></listitem>
730
<term><userinput>w</userinput></term>
731
<listitem><para>Match whole words only.</para></listitem>
740
<term><cmdsynopsis><command>ifind</command><arg choice="req">STRING pattern</arg></cmdsynopsis></term>
741
<listitem><para>This command provides <quote>as-you-type</quote> searching. You
742
can configure the behavior of the search by appending a colon
743
followed by one or more options, like this:
744
<userinput>ifind:options pattern</userinput>. Allowed options are
748
<term><userinput>b</userinput></term>
749
<listitem><para>Search backwards.</para></listitem>
753
<term><userinput>r</userinput></term>
754
<listitem><para>Do regular expression search.</para></listitem>
758
<term><userinput>s</userinput></term>
759
<listitem><para>Do case sensitive search.</para></listitem>
763
<term><userinput>c</userinput></term>
764
<listitem><para>Search from cursor position.</para></listitem>
776
<sect3 id="advanced-editing-tools-commandline-commands-basic">
777
<title>Commands for Basic Editor Functions (These depend on the application the editor component is used in)</title>
782
<term><cmdsynopsis><command>w</command></cmdsynopsis></term>
783
<listitem><para>Save the current document.</para></listitem>
787
<term><cmdsynopsis><command>wa</command></cmdsynopsis></term>
788
<listitem><para>Save all currently open documents.</para></listitem>
792
<term><cmdsynopsis><command>q</command></cmdsynopsis></term>
793
<listitem><para>Close the current document.</para></listitem>
797
<term><cmdsynopsis><command>qa</command></cmdsynopsis></term>
798
<listitem><para>Close all open documents.</para></listitem>
802
<term><cmdsynopsis><command>wq</command></cmdsynopsis></term>
803
<listitem><para>Save and close the current document.</para></listitem>
807
<term><cmdsynopsis><command>wqa</command></cmdsynopsis></term>
808
<listitem><para>Save and close all currently open documents.</para></listitem>
812
<term><cmdsynopsis><command>x</command></cmdsynopsis></term>
813
<listitem><para>Save and close the current document only if it has changed.
818
<term><cmdsynopsis><command>x</command></cmdsynopsis></term>
819
<listitem><para>Save and close all currently open documents only if they have
820
changed.</para></listitem>
824
<term><cmdsynopsis><command>bp</command></cmdsynopsis></term>
825
<listitem><para>Go to the previous document in the documents list.
830
<term><cmdsynopsis><command>bn</command></cmdsynopsis></term>
831
<listitem><para>Go to the next document in the documents list.
836
<term><cmdsynopsis><command>new</command></cmdsynopsis></term>
837
<listitem><para>Open a new document in horizontal split view.
842
<term><cmdsynopsis><command>vnew</command></cmdsynopsis></term>
843
<listitem><para>Open a new document in vertical split view.
848
<term><cmdsynopsis><command>e</command></cmdsynopsis></term>
849
<listitem><para>Reload the current document if it has changed on disk.
854
<term><cmdsynopsis><command>enew</command></cmdsynopsis></term>
855
<listitem><para>Edit a new document.
860
<term><cmdsynopsis><command>print</command></cmdsynopsis></term>
861
<listitem><para>Open the Print dialog to print the current document.
874
<sect1 id="advanced-editing-tools-code-folding">
875
<title>Using Code Folding</title>
877
<para>Code folding allows you to hide parts of a document in the editor, making
878
it easier to overview large documents. In &kappname; the foldable regions are
879
calculated using rules defined in the syntax highlight definitions, and
880
therefore it is only available in some formats - typically program source code,
881
XML markup and similar. Most highlight definitions supporting code folding
882
also lets you manually define foldable regions, typically using the
883
<userinput>BEGIN</userinput> and <userinput>END</userinput> keywords.</para>
885
<para>To use the code folding feature, activate the folding markers using
886
<menuchoice><guimenu>View</guimenu><guimenuitem>Show Folding
887
Markers</guimenuitem></menuchoice> menu item if they are not already visible.
888
The Folding Markers Pane on the left side of the screen displays a graphical
889
view of the foldable regions, with triangle symbols to indicate the possible operation
890
on a given region: a top down triangle means that the region is expanded, clicking it will
891
collapse the region and a right pointing triangle will be displayed instead.</para>
892
<!--FIXME change Three to Four when Unfold Toplevel Nodes action is back-->
893
<para>Three commands are provided to manipulate the state of folding regions,
894
see the <link linkend="view-code-folding">menu documentation</link>.
897
<para>The folded lines are remembered when a file is closed, so when you reopen
898
the file the folded nodes will still be folded. This applies to reload operations
901
<para>If you do not want to use the code folding feature, you can disable
902
the <guilabel>Show folding markers (if available)</guilabel> option in the
903
<link linkend="appearance">Appearance</link> page of the editor
904
configuration.</para>