summaryrefslogtreecommitdiffstats
path: root/doc/kate/advanced.docbook
blob: d1643712107d5772cc27c554ca80d4aa5ce86772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
<chapter id="advanced-editing-tools">
<chapterinfo>
<authorgroup>
<author>&Anders.Lund; &Anders.Lund.mail;</author>
<author>&Dominik.Haumann; &Dominik.Haumann.mail;</author>
<!-- TRANS:ROLES_OF_TRANSLATORS -->
</authorgroup>
</chapterinfo>
<title>Advanced Editing Tools</title>

<sect1 id="advanced-editing-tools-comment">

<title>Comment/Uncomment</title>

<para>The Comment and Uncomment commands, available from the
<guimenu>Tools</guimenu> menu allow you to add or remove comment
markers to the selection, or the current line if no text is selected,
if comments are supported by the format of the text you are
editing.</para>

<para>The rules for how commenting is done are defined in the syntax
definitions, so if syntax highlighting is not used, commenting/uncommenting
is not possible. </para>

<para>Some formats define single line comment markers, some multiline
markers and some both.  If multiline markers are not available,
commenting out a selection that does not fully include its last line
is not possible.</para>

<para>If a single line marker is available, commenting single lines is
preferred where applicable, as this helps to avoid problems with
nested comments.</para>

<para>When removing comment markers, no uncommented text should be
selected. When removing multiline comment markers from a selection,
any whitespace outside the comment markers is ignored.</para>

<para><indexterm><primary>comment</primary></indexterm>
To place comment markers, use the
<menuchoice><guimenu>Tools</guimenu><guimenuitem>Comment</guimenuitem></menuchoice>
menu item or the related keyboard shortcut sequence, default is
<keycombo action="simul">&Ctrl;<keycap>D</keycap></keycombo>.</para>

<para><indexterm><primary>uncomment</primary></indexterm>
To remove comment markers, use the
<menuchoice><guimenu>Tools</guimenu><guimenuitem>Uncomment</guimenuitem></menuchoice>
menu item or the related keyboard shortcut, default is <keycombo
action="simul">&Ctrl;&Shift;<keycap>D</keycap></keycombo>.</para>

</sect1>

<sect1 id="advanced-editing-tools-commandline">
<title>The Editor Component Command Line</title>

<para>Kate's editor component has an internal command line, allowing you to
perform various actions from a minimal GUI. The command line is a text entry
in the bottom of the editor area, to show it select
<menuchoice><guimenu>View</guimenu><guimenuitem>Switch to Command Line</guimenuitem></menuchoice>
or use the shortcut (default is
<keycombo action="simul"><keycap>F7</keycap></keycombo>). The editor provides
a set of commands as documented below, and additional commands can be provided
by plugins.</para>

<para>To execute a command, type the comand then press the return key. The
command line will indicate wether it succeded and possibly display a message. If
you entered the command line by pressing <keycap>F7</keycap> it will
automatically hide after a few seconds. To clear the message and enter a new
command, press <keycap>F7</keycap> again.</para>

<para>The command line has a built-in help system, issue the command
<command>help</command> to get started. To see a list of all available commands
issue <command>help list</command>, to view help for a specific command, do
<command>help <replaceable>command</replaceable></command>.</para>

<para>The command line has a built in history, so you can reuse commands already
typed. To navigate the history, use the <keycap>Up</keycap> and
<keycap>Down</keycap> keys. When showing historical commands, the argument part
of the command will be selected, allowing you to easily overwrite the
arguments.</para>

<sect2 id="advanced-editing-tools-commandline-commands">
<title>Standard Command Line Commands</title>

<sect3 id="advanced-editing-tools-commandline-commands-configure">
<title>Commands for Configuring the Editor</title>

<para>These commands are provided by the editor component, and allows you to
configure the active document and view only. This is handy if you want to use
a setting different from the default settings, for example for indentation.
</para>

<variablelist>
<title>Argument types</title>

<varlistentry>
<term>BOOLEAN</term>
<listitem><para>This is used with commands that turns things on or off.
Legal values are <userinput>on</userinput>, <userinput>off</userinput>,
<userinput>true</userinput>, <userinput>false</userinput>,
<userinput>1</userinput> or <userinput>0</userinput></para></listitem>
</varlistentry>

<varlistentry>
<term>INTEGER</term>
<listitem><para>An integer number</para></listitem>
</varlistentry>

<varlistentry>
<term>STRING</term>
<listitem><para>A string</para></listitem>
</varlistentry>

</variablelist>

<variablelist>

<varlistentry>
<term><cmdsynopsis><command>set-tab-width</command><arg>INTEGER width</arg></cmdsynopsis></term>
<listitem><para>Sets the tab width to the number <userinput>width</userinput></para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-indent-width</command><arg>INTEGER width</arg></cmdsynopsis></term>
<listitem><para>Sets the indentation width to the number
<userinput>width</userinput>. Used only if you are indenting with
spaces.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-word-wrap-column</command><arg>INTEGER width</arg></cmdsynopsis></term>
<listitem><para>Sets the line width for hard wrapping to
<userinput>width</userinput>. This is used if you are having your text wrapped
automatically.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-icon-border</command><arg>BOOLEAN enable</arg>
</cmdsynopsis></term>
<listitem><para>Sets the visibility of the icon border.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-folding-markers</command><arg>BOOLEAN enable</arg></cmdsynopsis></term>
<listitem><para>Sets the visibility of the folding markers pane.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-line-numbers</command><arg>BOOLEAN enable</arg></cmdsynopsis></term>
<listitem><para>Sets the visibility of the line numbers pane.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-replace-tabs</command><arg>BOOLEAN enable</arg></cmdsynopsis></term>
<listitem><para>If enabled, tabs are replaced with spaces as you type.
</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-remove-trailing-space</command><arg>BOOLEAN enable</arg></cmdsynopsis></term>
<listitem><para>If enabled, trailing whitespace are removed whenever the cursor
leaves a line.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-show-tabs</command><arg>BOOLEAN enable</arg></cmdsynopsis></term>
<listitem><para>If enabled, TAB characters and trailing whitespace will be
visualized by a small dot.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-indent-spaces</command><arg>BOOLEAN enable</arg></cmdsynopsis></term>
<listitem><para>If enabled, the editor will indent with
<option>indent-width</option> spaces for each indentation level, rather than
with one TAB character.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-mixed-indent</command><arg>BOOLEAN enable</arg></cmdsynopsis></term>
<listitem><para>If enabled, kate will use a mix of TAB and spaces for
indentation. Each indentation level will be <option>indent-width</option> wide,
and more indentation levels will be optimized to use as many TAB characters as
possible.</para>
<para>When executed, this command will additionally set space indentation enabled,
and if the indent width is unspecified it will be set to half of the
<option>tab-width</option> for the document at the time of execution.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-word-wrap</command><arg>BOOLEAN 
enable</arg></cmdsynopsis></term>
<listitem><para>Enables dynamic word wrap according to
<userinput>enable</userinput></para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-replace-tabs-save</command><arg>BOOLEAN enable
</arg></cmdsynopsis></term>
<listitem><para>When enabled, tabs will be replaced with whitespace whenever
 the document is saved.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-remove-trailing-space-save</command><arg>BOOLEAN enable</arg></cmdsynopsis></term>
<listitem><para>When enabled, trailing space will be removed from each line
whenever the document is saved.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-indent-mode</command><arg>name</arg></cmdsynopsis></term>
<listitem><para>Sets the autoindentation mode to <userinput>name</userinput>.
If <userinput>name</userinput> is not known, the mode is set to 'none'. Valid
modes are 'cstyle', 'csands', 'xml', 'python', 'varindent' and 'none'.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>set-highlight</command><arg>highlight</arg></cmdsynopsis></term>
<listitem><para>Sets the syntax highlighting system for the document. The
argument must be a valid highlight name, as seen in the
<menuchoice><guimenu>Tools</guimenu><guisubmenu>Highlighting</guisubmenu></menuchoice>
menu. This command provides an autocompletion list for its
argument.</para></listitem>
</varlistentry>

</variablelist>

</sect3>

<sect3 id="advanced-editing-tools-commandline-commands-edit">
<title>Commands for editing</title>

<para>These commands modify the current document.</para>

<variablelist>
<varlistentry>
<term><cmdsynopsis><command>indent</command></cmdsynopsis></term>
<listitem><para>Indents the selected lines or the current line.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>unindent</command></cmdsynopsis></term>
<listitem><para>Unindents the selected lines or current line.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>cleanindent</command></cmdsynopsis></term>
<listitem><para>Cleans up the indentation of the selected lines or current line
according to the indentation settings in the document.
</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>comment</command></cmdsynopsis></term>
<listitem><para>Inserts comment markers to make the selection or selected lines
or current line a comment according to the text format as defined by the syntax
highlight definition for the document.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>uncomment</command></cmdsynopsis></term>
<listitem><para>Removes comment markers from the selection or selected lines
or current line according to the text format as defined by the syntax highlight
definition for the document.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>kill-line</command></cmdsynopsis></term>
<listitem><para>Deletes the current line.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>replace</command><arg>pattern</arg><arg>replacement</arg></cmdsynopsis></term>
<listitem><para>Replaces text matching <userinput>pattern</userinput> with
<userinput>replacement</userinput>. If you want to include whitespace in the
<userinput>pattern</userinput>, you must quote both the <userinput>pattern</userinput>
and <userinput>replacement</userinput> with single or double quotes. If the
arguments are unquoted, the first word is used as <userinput>pattern</userinput>
and the rest for <userinput>replacement</userinput>. If
<userinput>replacement</userinput> is empty, each occurrence of
<userinput>pattern</userinput> is removed.</para>
<para>You can set flags to configure the search by adding a colon, followed
by one or more letters each representing a configuration, giving the form
<userinput>replace:options pattern replacement</userinput>. Available options
are:

<variablelist>

<varlistentry>
<term><userinput>b</userinput></term>
<listitem><para>Search backwards.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>c</userinput></term>
<listitem><para>Search from cursor position.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>e</userinput></term>
<listitem><para>Search in the selection only.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>r</userinput></term>
<listitem><para>Do regular expression search. If set, you may use
<userinput>\N</userinput> where N is a number to represent captures in the
replacement string.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>s</userinput></term>
<listitem><para>Do case sensitive search.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>p</userinput></term>
<listitem><para>Prompt for permission to replace the next occurence.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>w</userinput></term>
<listitem><para>Match whole words only.</para></listitem>
</varlistentry>

</variablelist>

</para>
</listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>date</command><arg>format</arg></cmdsynopsis></term>
<listitem><para>Inserts a date/time string as defined by the specified
<userinput>format</userinput>, or the format <quote>yyyy-MM-dd hh:mm:ss</quote>
if none is specified. The following translations are done when interpreting
<userinput>format</userinput>:

<informaltable>
<tgroup cols="2">
<tbody>
<row><entry><literal>d</literal></entry><entry>The day as number without a leading zero (1-31).</entry></row>
<row><entry><literal>dd</literal></entry><entry>The day as number with a leading zero (01-31).</entry></row>
<row><entry><literal>ddd</literal></entry><entry>The abbreviated localized day name (e.g. 'Mon'..'Sun').</entry></row>
<row><entry><literal>dddd</literal></entry><entry>The long localized day name (e.g. 'Monday'..'Sunday').</entry></row>
<row><entry><literal>M</literal></entry><entry>The month as number without a leading zero (1-12).</entry></row>
<row><entry><literal>MM</literal></entry><entry>The month as number with a leading zero (01-12).</entry></row>
<row><entry><literal>MMM</literal></entry><entry>The abbreviated localized month name (e.g. 'Jan'..'Dec').</entry></row>
<row><entry><literal>yy</literal></entry><entry>The year as two digit number
(00-99).</entry></row>
<row><entry><literal>yyyy</literal></entry><entry>The year as four digit number (1752-8000).</entry></row>
<row><entry><literal>h</literal></entry><entry>The hour without a leading zero (0..23 or 1..12 if AM/PM display).</entry></row>
<row><entry><literal>hh</literal></entry><entry>The hour with a leading zero (00..23 or 01..12 if AM/PM display).</entry></row>
<row><entry><literal>m</literal></entry><entry>The minute without a leading zero (0..59).</entry></row>
<row><entry><literal>mm</literal></entry><entry>The minute with a leading zero (00..59).</entry></row>
<row><entry><literal>s</literal></entry><entry>The second without a leading zero (0..59).</entry></row>
<row><entry><literal>ss</literal></entry><entry>The second with a leading zero (00..59).</entry></row>
<row><entry><literal>z</literal></entry><entry>The milliseconds without leading zeroes (0..999).</entry></row>
<row><entry><literal>zzz</literal></entry><entry>The milliseconds with leading zeroes (000..999).</entry></row>
<row><entry><literal>AP</literal></entry><entry>Use AM/PM display. AP will be replaced by either "AM" or "PM".</entry></row>
<row><entry><literal>ap</literal></entry><entry>Use am/pm display. ap will be replaced by either "am" or "pm".</entry></row>

</tbody>
</tgroup>
</informaltable>

</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>char</command><arg>identifier</arg></cmdsynopsis></term>
<listitem>
<para>This command allows you to insert literal characters by their
numerical identifier, in decimal, octal or hexadecimal form.
To use it launch the Editing Command dialog and type <userinput>char:
[number]</userinput> in the entry box, then hit
<guibutton>OK</guibutton>.</para>

<example>
<title><command>char</command> examples</title>

<para>Input: <userinput>char:234</userinput></para>
<para>Output: <computeroutput>&#234;</computeroutput></para>
<para>Input: <userinput>char:0x1234</userinput></para>
<para>Output: <computeroutput>&#x1234;</computeroutput></para>
</example>

</listitem>
</varlistentry>

<varlistentry>
<term>
<indexterm><primary>replace, sed style</primary>
<secondary>search, sed style</secondary></indexterm>
<command>s///[ig]</command> <command>%s///[ig]</command></term>

<listitem>
<para>This command does a sed-like search/replace operation on the
current line, or on the whole file (<command>%s///</command>).</para>

<para>In short, the text is searched for text matching the
<emphasis>search pattern</emphasis>, the regular expression between
the first and the second slash, and when a match is found, the
matching part of the text is replaced with the expression between the
middle and last part of the string. Parentheses in the search pattern
create <emphasis>back references</emphasis>, that is the command
remembers which part of the match matched in the parentheses; these
strings can be reused in the replace pattern, referred to as
<userinput>\1</userinput> for the first set of parentheses,
<userinput>\2</userinput> for the second and so on.</para>

<para>To search for a literal <literal>(</literal> or
<literal>)</literal>, you need to <emphasis>escape</emphasis> it using
a backslash character: <userinput>\(\)</userinput></para>

<para>If you put an <userinput>i</userinput> at the end of the
expression, the matching will be case insensitive. If you put a
<userinput>g</userinput> at the end, all occurrences of the pattern will be
replaced, otherwise only the first occurrence is replaced.</para>

<example>

<title>Replacing text in the current line</title>

<para>Your friendly compiler just stopped, telling you that the class
<classname>myClass</classname> mentioned in line 3902 in your source file
is not defined.</para>

<para>&quot;Buckle!&quot; you think, it is of course
<classname>MyClass</classname>. You go to line 3902, and instead of trying
to find the word in the text, you launch the Editing Command Dialog,
enter <userinput>s/myclass/MyClass/i</userinput>, hit the
<guibutton>OK</guibutton> button, save the file and compile &ndash;
successfully without the error.</para>

</example>

<example>
<title>Replacing text in the whole file</title>

<para>Imagine that you have a file, in which you mention a <quote>Miss
Jensen</quote> several times, when someone comes in and tells you that
she just got married to <quote>Mr Jones</quote>. You want, of course,
to replace each and every occurrence of <quote>Miss Jensen</quote>
with <quote>Ms Jones</quote>.</para>

<para>Enter the command line and issue the command
<userinput>%s/Miss Jensen/Ms Jones/</userinput> and hit return, you
are done.</para>

</example>

<example>
<title>A More Advanced Example</title>

<para>This example makes use of <emphasis>back references</emphasis>
as well as a <emphasis>character class</emphasis> (if you do not know what
that is, please refer to the related documentation mentioned
below).</para>

<para>Suppose you have the following line:

<programlisting>void MyClass::DoStringOps( String      &amp;foo, String &amp;bar String *p, int  &amp;a, int &amp;b )</programlisting>
</para>
<para>Now you realize that this is not nice code, and decide that you
want to use the <constant>const</constant> keyword for all
<quote>address of</quote> arguments, those characterized by the &amp;
operator in front of the argument name. You would also like to
simplify the white space, so that there is only 1 whitespace character
between each word.</para>

<para>Launch the Editing Command Dialog, and enter:
<userinput>s/\s+(\w+)\s+(&amp;)/ const \1 \2/g</userinput> and hit the
<guibutton>OK</guibutton> button. The <userinput>g</userinput> at the end of the expression makes
the regular expression recompile for each match to save the <emphasis>backreferences</emphasis>.</para>

<para>Output:

<computeroutput>void MyClass::DoStringOps( const String &amp;foo, const String &amp;bar String *p, const int &amp;a, const int &amp;b )</computeroutput></para>

<para>Mission completed! Now, what happened? Well, we looked for some
white space (<literal>\s+</literal>) followed by one or more
alphabetic characters (<literal>\w+</literal>) followed by some more
whitespace (<literal>\s+</literal>) followed by an ampersand, and in
the process saved the alphabetic chunk and the ampersand for reuse in
the replace operation. Then we replaced the matching part of our line
with one whitespace followed by <quote>const</quote> followed by one
whitespace followed by our saved alphabetical chunk
(<literal>\1</literal>) followed by one whitespace followed by our
saved ampersand (<literal>\2</literal>)</para>

<para>Now in some cases the alphabetical chunk was
<quote>String</quote>, in some <quote>int</quote>, so using the
character class <literal>\w</literal> and the <literal>+</literal>
quantifier proved a valuable asset.</para>

</example>

</listitem>

</varlistentry>

</variablelist>

</sect3>

<sect3 id="advanced-editing-tools-commandline-commands-navigation">
<title>Commands for navigation</title>

<variablelist>

<varlistentry>
<term><cmdsynopsis><command>goto</command><arg>INT line</arg></cmdsynopsis></term>
<listitem><para>This command navigates to the specified line.</para></listitem>
</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>find</command><arg>pattern</arg></cmdsynopsis></term>
<listitem><para>This command navigates to the first occurrence of
<userinput>pattern</userinput> according to the configuration. Following
occurrences can be found using
<menuchoice><guimenu>Edit</guimenu><guimenuitem>Find Next</guimenuitem></menuchoice>
(the default shortcut is <keycap>F3</keycap>).</para>
<para>The find command can be configured by appending a colon followed by one or
more options, the form is
<userinput>find:options pattern</userinput>. The
following options are supported:

<variablelist>

<varlistentry>
<term><userinput>b</userinput></term>
<listitem><para>Search backwards.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>c</userinput></term>
<listitem><para>Search from cursor position.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>e</userinput></term>
<listitem><para>Search in the selection only.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>r</userinput></term>
<listitem><para>Do regular expression search. If set, you may use
<userinput>\N</userinput> where N is a number to represent captures in the
replacement string.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>s</userinput></term>
<listitem><para>Do case sensitive search.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>w</userinput></term>
<listitem><para>Match whole words only.</para></listitem>
</varlistentry>

</variablelist>

</para>

</listitem>

</varlistentry>

<varlistentry>
<term><cmdsynopsis><command>ifind</command><arg>pattern</arg></cmdsynopsis></term>
<listitem><para>This command provides <quote>as-you-type</quote> searching. You
can configure the behavior of the search by appending a colon
followed by one or more options, like this:
<userinput>ifind:options pattern</userinput>. Allowed options are

<variablelist>
<varlistentry>
<term><userinput>b</userinput></term>
<listitem><para>Search backwards.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>r</userinput></term>
<listitem><para>Do regular expression search.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>s</userinput></term>
<listitem><para>Do case sensitive search.</para></listitem>
</varlistentry>

<varlistentry>
<term><userinput>c</userinput></term>
<listitem><para>Search from cursor position.</para></listitem>
</varlistentry>

</variablelist>
</para></listitem>
</varlistentry>

</variablelist>

</sect3>

</sect2>

</sect1>

<sect1 id="advanced-editing-tools-code-folding">
<title>Using Code Folding</title>

<para>Code folding allows you to hide parts of a document in the editor, making
it easier to overview large documents. In &kate; the foldable regions are
calculated using rules defined in the syntax highlight definitions, and
therefore it is only available in some formats - typically program source code,
XML markup and similar. Most highlight definitions supporting code folding
also lets you manually define foldable regions, typically using the
<userinput>BEGIN</userinput> and <userinput>END</userinput> keywords.</para>

<para>To use the code folding feature, activate the folding markers using
<menuchoice><guimenu>View</guimenu><guimenuitem>Show Folding
Markers</guimenuitem></menuchoice> menu item if they are not already visible.
The Folding Markers Pane in the left side of the screen displays a graphical
view of the foldable regions, with +/- signs to indicate the possible operation
on a given region: a - means that the region is expanded, clicking the - will
collapse the region and a + will be displayed instead.</para>

<para>Four commands are provided to manipulate the state of folding regions,
see the <link linkend="view-code-folding">menu documentation</link>.
</para>

<para>If you do not want to use the code folding feature, you can disable
the <guilabel>Show folding markers (if available)</guilabel> option in the
<link linkend="config-dialog-editor-appearance">Appearance page of the editor
configuration</link></para>

</sect1>

<sect1 id="advanced-editing-tools-scripting">

<title>Scripting the editor component with Javascript</title>

<sect2 id="advanced-editing-tools-scripting-introduction">

<title>Introduction</title>

<para>Starting with version 2.5, the &kate; editor component supports
scripting with ECMA script, also known as JavaScript.</para>

<para>Scripts can be used through <link
linkend="advanced-editing-tools-commandline">the built in command line</link>
only. The requirements is that the script is placed in a folder where &kate;
can find it, along with an optional .desktop file that defines the related
properties. The valid folder are named <filename>katepart/scripts</filename>
in the &tde; data folders. You can find the data folders by running the command
<command>tde-config <option>--path</option> <parameter>data</parameter></command>
You will usually have at least a system and a personal data folder. Of course
scripts in the system data folder are available to all users on the system,
while those in the personal folder are available for you only.</para>

<note><para>This feature is experimental and will most likely change during
future development.</para>
<para>We know that many of you will be disappointed because you can't add
your scripts to the menu or assign shortcuts to them. Sorry, sometime
in the future that will likely be possible.</para>
<para>It is also not possible to pass any arguments to your scripts yet. Be
patient, and that may be added in the bright future ;)</para>
</note>

</sect2>

<sect2 id="advanced-editing-tools-scripting-reference">

<title>The Kate JavaScript API</title>

<para>Here is listed the complete set of functions and properties available
in the <type>document</type> and <type>view</type> objects.
In addition you can of course use all the standard objects such as
<type>Math</type>, <type>String</type> <type>Regex</type> and so forth.</para>

<para>When a script is run, the <classname>document</classname> object is the
current document, and the <classname>view</classname> object is the current
view.</para>

<note><para>The types of arguments are of course not used in JavaScript at
this time, they are there solely to indicate what sort of value the funcitons
expect.</para></note>

<variablelist id="advanced-editing-tools-scripting-global">
<title>Global Functions</title>
<varlistentry>
<term><function>debug( <parameter><replaceable>string</replaceable></parameter>)
[function]</function></term>
<listitem>
<itemizedlist>
<title>parameters</title>
<listitem><para><parameter>string</parameter> the string to output</para>
</listitem>
</itemizedlist>
<para>Outputs the string to <acronym>STDERR</acronym> using
<function>kdDebug()</function>. A dedicated output area is used for the output,
which will be prefixed <computeroutput>Kate (KJS Scripts):</computeroutput>
</para>
</listitem>
</varlistentry>
</variablelist>

<variablelist id="advanced-editing-tools-scripting-document">
<title>The <classname>document</classname> API</title>

<varlistentry>
<term><function>document.attribute( <parameter><replaceable>line</replaceable>
</parameter>, <parameter><replaceable>column</replaceable></parameter> );
 [function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>uint line</parameter> The line of the position for which
to find the attribute.</para></listitem>
<listitem><para><parameter>uint column</parameter> The column of the position for
which to find the attribute.</para></listitem>
</itemizedlist>
<para>Returns the numeric ID of the attribute for the document position
[<parameter>line</parameter>,<parameter>column</parameter>]. The attribute
represents the visual appearance or style of the text, and is also used to
calculate the syntax highlight for a specific part of the text in mixed formats
like HTML or PHP.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.canBreakAt( <parameter>Char c</parameter>,
<parameter>uint attribute</parameter> ); [function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>c</parameter> The character to test</para></listitem>
<listitem><para><parameter>attribute</parameter> The attribute at the position
of <parameter>c</parameter>.</para></listitem>
</itemizedlist>
<para>Returns whether it is allowed to break the line at a character c with
attribute attribute. The result is decided by querying the highlight owning
attribute for which characters allow breaking the line.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.canComment( <parameter>uint start_attribute</parameter>,
<parameter>uint end_attribute</parameter> ); [function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>start_attribute</parameter> The attribute at the
start of the range to turn into a comment.</para></listitem>
<listitem><para><parameter>end_attribute</parameter> The attribute at end of
the range to turn into a comment.</para></listitem>
</itemizedlist>
<para>Returns whether start_attribute and end_attribute belongs to the same
syntax highlight system. If they do, it is sane.
</para>
<example>
<title>using canComment</title>
<programlisting>
if ( document.canComment( document.attribute(1,0), document.attribute(5,0) ) ) {
    // 1,0 and 5,0 belongs to the same syntax highlighting system
}
</programlisting>
</example>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.clear(); [function]</function></term>
<listitem><para>Clears the document.</para></listitem>
</varlistentry>

<varlistentry>
<term><function>document.commentStart( <parameter>uint attribute</parameter> );
[function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>attribute</parameter> The attribute of the text for
which to get the commentStart string.</para></listitem>
</itemizedlist>
<para>Returns the string required to start a multiline comment for a text with
attribute, or an empty string if multiline comments are not supported for that
text.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.commentMarker( <parameter>uint attribute</parameter> );
[function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>attribute</parameter> The attribute of the text for
which to get the commentMarker string</para></listitem>
</itemizedlist>
<para>Returns the string used to mark the rest of the line as a comment for a
text with attribute or an empty string if single line comments are not supported
for that text.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.commentEnd( <parameter>uint attribute</parameter> );
[function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>attribute</parameter> The attribute of the text for
which to get the commentEnd string</para></listitem>
</itemizedlist>
<para>Returns the string required to end a multiline comment for a text with
attribute, or an empty string if multiline comments are not supported for that
text.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.editBegin(); [function]</function></term>
<listitem>
<para>Start an editing group. All actions done until the call of editEnd() will
be grouped as one undo-action.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.editEnd(); [function]</function></term>
<listitem>
<para>Finish an editing group.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.highlightMode; [property:read only]</function></term>
<listitem>
<para>The name of the document's highlight mode, such as JavaScript or C++.
If no syntax highlight mode is set for the document, the value is None. Notice
that you need to use the English name in cases where it differs from the
translated one.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.indentMode; [property:read only]</function></term>
<listitem>
<para>The name of the document indent mode, such as
<literal>normal</literal> or <literal>cstyle</literal>.
Remember that if no indent mode is set, the value is <literal>none</literal>.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.indentWidth; [property:read only]</function></term>
<listitem>
<para>The indentation width set for the document. This is used if space
indenting is enabled.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.insertLine( <parameter>uint line</parameter>,
<parameter>string text</parameter> ); [function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>line</parameter> document line number</para>
</listitem>
<listitem><para><parameter>text</parameter> text to insert</para></listitem>
</itemizedlist>
<para>Inserts a new line with the text <parameter>text</parameter> at the
line <parameter>line</parameter>.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.insertText( <parameter>uint line</parameter>,
<parameter>uint column</parameter>, <parameter>string text</parameter> );
[function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>line</parameter> the line number</para></listitem>
<listitem><para><parameter>column</parameter> the column</para></listitem>
<listitem><para><parameter>text</parameter> the text which is to be
inserted</para></listitem>
</itemizedlist>
<para>Inserts the text <parameter>text</parameter> in line
<parameter>line</parameter> and column <parameter>column</parameter>.</para>
</listitem>
</varlistentry>

<varlistentry>
<term>document.length(); [function]</term>
<listitem>
<para>Returns the document's size in bytes.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.lines(); [function]</function></term>
<listitem>
<para>Returns the number of lines in the document.</para>
</listitem>
</varlistentry>

<varlistentry>
<term>document.mixedIndent; [property:read only]</term>
<listitem>
<para>A boolean telling whether the mixed-indent setting is enabled for the
document. If so, indentation is optimized to contain a mix of tab characters and
spaces like used by the Emacs editor.</para>
</listitem>
</varlistentry>

<varlistentry>
<term>document.removeLine( <parameter>uint line</parameter> ); [function]</term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>line</parameter> line number</para></listitem>
</itemizedlist>
<para>Removes the document line line.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.removeText( <parameter>uint startLine</parameter>,
<parameter>uint startColumn</parameter>, <parameter>uint endLine</parameter>,
<parameter>uint endColumn</parameter> ); [function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>startLine</parameter> specifies the beginning
line</para></listitem>
<listitem><para><parameter>startColumn</parameter> specifies the beginning
column</para></listitem>
<listitem><para><parameter>endLine</parameter> specifies the ending
line</para></listitem>
<listitem><para><parameter>endColumn</parameter> specifies the ending
column</para></listitem>
</itemizedlist>
<para>Removes the text range from line <parameter>startLine</parameter> and
column <parameter>startColumn</parameter> up to line
<parameter>endLine</parameter> and column <parameter>endColumn</parameter>.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.setText( <parameter>string text</parameter> );
[function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>text</parameter> document text</para></listitem>
</itemizedlist>
<para>Sets the entire document content to <parameter>text</parameter>.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.spaceIndent; [property:read only]</function></term>
<listitem>
<para>A boolean telling whether space-indent is enabled for the document.
If so, the document is indented with indentWidth spaces pr level, otherwise
indentation is one tab character pr. level.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.textFull(); [function]</function></term>
<listitem>
<para>Returns the full document text. If the text spans over multiple lines the
linefeed character is <constant>\n</constant>.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.textLine( uint line ); [function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>line</parameter> the line</para></listitem>
</itemizedlist>
<para>Returns the text of line <parameter>line</parameter>.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>document.textRange( <parameter>uint startLine</parameter>,
<parameter>uint startColumn</parameter>, <parameter>uint endLine</parameter>,
<parameter>uint endColumn</parameter> ); [function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>startLine</parameter> specifies the beginning
line</para></listitem>
<listitem><para><parameter>startColumn</parameter> specifies the beginning
column</para></listitem>
<listitem><para><parameter>endLine</parameter> specifies the ending line</para>
</listitem>
<listitem><para><parameter>endColumn</parameter> specifies the ending
column</para></listitem>
</itemizedlist>
<para>Returns the specified text range. If the range spans over multiple lines
the linefeed character is <constant>\n</constant>.</para>
</listitem>
</varlistentry>

</variablelist><!--/ document API -->

<variablelist id="advanced-editing-tools-scripting-view">
<title>The <classname>view</classname> API</title>

<varlistentry>
<term><function>view.clearSelection(); [function]</function></term>
<listitem>
<para>Deselects all text.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.cursorColumn(); [function]</function></term>
<listitem>
<para>Returns the current cursor column (TAB characters are expanded).</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.cursorColumnReal(); [function]</function></term>
<listitem>
<para>Returns the current real cursor column (TAB characters counts one).</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.cursorLine(); [function]</function></term>
<listitem>
<para>Returns the current cursor line.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.hasSelection(); [function]</function></term>
<listitem>
<para>Returns <constant>true</constant> if the view contains selected text,
otherwise <constant>false</constant>.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.removeSelectedText(); [function]</function></term>
<listitem>
<para>Removes the selected text, if the view has a selection.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.selectAll(); [function]</function></term>
<listitem>
<para>Selects all text.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.selection(); [function]</function></term>
<listitem>
<para>Returns the selected text. If the selection spans over multiple lines the
linefeed character is <constant>\n</constant>.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.selectionEndColumn; [property:read only]</function></term>
<listitem>
<para>Returns the ending column of the selection.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.selectionEndLine; [property:read only]</function></term>
<listitem>
<para>Returns the ending line of the selection.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.selectionStartColumn; [property:read only]</function></term>
<listitem>
<para>Returns the starting column of the selection.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.selectionStartLine; [property:read only]</function></term>
<listitem>
<para>Returns the starting line of the selection.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.setCursorPosition( <parameter>uint line</parameter>,
<parameter>uint column</parameter> ); [function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>line</parameter> Specifies the line for the
cursor.</para></listitem>
<listitem><para><parameter>column</parameter> Specifies the column for the
cursor.</para></listitem>
</itemizedlist>
<para>Sets the input cursor position in the view to [<parameter>line</parameter>,
<parameter>col</parameter>]. This sets the cursor position by visual means,
that is the a TAB character counts up to <replaceable>tabwidth</replaceable>
depending on the position inside the line. The cursor position is made visible.
Both line and column are zero-based.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.setCursorPositionReal( <parameter>uint line</parameter>,
<parameter>uint column</parameter> ); [function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>line</parameter> Specifies the line for the
cursor.</para></listitem>
<listitem><para><parameter>column</parameter> Specifies the column for the
cursor.</para></listitem>
</itemizedlist>
<para>Sets the input cursor position to [<parameter>line</parameter>,
<parameter>col</parameter>]. This sets the string position, that is a TAB
character counts for 1. The cursor position is made visible. Both line and
column are zero-based.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><function>view.setSelection( <parameter>uint startLine</parameter>,
<parameter>uint startColumn</parameter>, <parameter>uint endLine</parameter>,
<parameter>uint endColumn</parameter> ); [function]</function></term>
<listitem>
<itemizedlist>
<title>Parameters</title>
<listitem><para><parameter>startLine</parameter> specifies the beginning line</para></listitem>
<listitem><para><parameter>startColumn</parameter> specifies the beginning column</para></listitem>
<listitem><para><parameter>endLine</parameter> specifies the ending line</para></listitem>
<listitem><para><parameter>endColumn</parameter> specifies the ending column</para></listitem>
</itemizedlist>
<para>Sets a selection from line <parameter>startLine</parameter> and column
<parameter>startColumn</parameter> up to line <parameter>endLine</parameter>
and column <parameter>endColumn</parameter>.</para>
</listitem>
</varlistentry>

</variablelist>

<example id="advanced-editing-tools-scripting-example">

<title>A sample script</title>
<para>As an example we will create a small script that uppercases the selection.
It is obvious that we first need to check whether a selection exists, if so we
get the text, change the case and then replace it with the new one. An
implementation could look like this:</para>

<programlisting>
if ( view.hasSelection() )
{
  // uppercase selection
  column = view.selectionStartColumn;
  line = view.selectionStartLine;

  selection = view.selection().toUpperCase();

  document.editBegin();
  view.removeSelectedText();
  document.insertText( line, column, selection );
  document.editEnd();
}
</programlisting>

<para>To group this action together so that they will be reverted by a single
activation of <guimenuitem>Undo</guimenuitem> we encapsulate the lines
<programlisting>view.removeSelectedText()</programlisting> and
<programlisting>document.insertText()</programlisting> with a
<programlisting>document.editBegin()</programlisting> and
<programlisting>document.editEnd()</programlisting>.</para>

</example>

<example id="advanced-editing-tools-desktop-example">
<title>A sample <filename>.desktop</filename> file</title>

<para>Here is a sample .desktop file that accompanies the above script.</para>

<programlisting>
# Example of a .desktop file
[Desktop Entry]
Encoding=UTF-8
Name=Kate Part JavaScript Uppercase
Comment=Script to uppercase the selection
X-Kate-Command=uppercase-selection
X-Kate-Help=&lt;p&gt;Usage: &lt;code&gt;uppercase-selection&lt;/code&gt;&lt;/p&gt;
</programlisting>

<para>As you can see you can define the Encoding, set a Name, a Comment, a help
text using X-Kate-Help and the command line name via X-Kate-Command. The entries
Name, Comment and X-Kate-Help are automatically translated into other languages
by the KDE translation teams, if the files are in KDE's SVN repository.</para>

</example>

<sect3>
<title>Putting it togeather</title>

<para>&kate; will search the script folders (see <link
linkend="advanced-editing-tools-scripting-introduction">above</link>)  for
<filename>*.js</filename> files. For every file it checks whether there is a
corresponding <filename>.desktop</filename> file, like for uppercase.js it
would look for uppercase.desktop. </para>
<para>If a <filename>.desktop</filename> file can not be found the script will
be registered in katepart's command line with the filename without the ending
.js, so in our example this would be <literal>uppercase</literal>. If the
command-name is fine and you don't need the extra features a
<filename>.desktop</filename> file provides you do not need a
<filename>.desktop</filename> file at all. </para>
<para>If a <filename>.desktop</filename> file exists katepart will read the name
under which the script will be registered from the .desktop-entry
X-Kate-Command, for example X-Kate-Command=uppercase-selection.</para>

</sect3>

</sect2>

</sect1>

</chapter>