The Editor Component Command Line
Prev
Next

The Editor Component Command Line

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 View->Switch to Command Line or use the keyboard shortcut (default is F7). The editor provides a set of commands as documented below, and additional commands can be provided by plugins.

To execute a command, type the command and then press the enter key. The command line will indicate whether it succeeded and possibly display a message. If you entered the command line by pressing F7 it will automatically hide after a few seconds. To clear the message and enter a new command, press F7 again.

The command line has a built-in help system, you can type the command help to get started. To see a list of all available commands type help list, to view help for a specific command, do help command.

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

Standard Command Line Commands

Argument types

BOOLEAN

This is used with commands that turn things on or off. Legal values are on, off, true, false, 1, 0

INTEGER

An integer number

STRING

A string

Commands for Configuring the Editor

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.

set-tab-width [INTEGER width]

Sets the tab width to the number width

set-indent-width [INTEGER width]

Sets the indentation width to the number width. Used only if you are indenting with spaces.

set-word-wrap-column [INTEGER width]

Sets the line width for hard wrapping to width. This is used if you are having your text wrapped automatically.

set-icon-border [BOOLEAN enable]

Sets the visibility of the icon border.

set-folding-markers [BOOLEAN enable]

Sets the visibility of the folding markers pane.

set-line-numbers [BOOLEAN enable]

Sets the visibility of the line numbers pane.

set-replace-tabs [BOOLEAN enable]

If enabled, tabs are replaced with spaces as you type.

set-remove-trailing-space [BOOLEAN enable]

If enabled, trailing whitespace are removed whenever the cursor leaves a line.

set-show-tabs [BOOLEAN enable]

If enabled, TAB characters and trailing whitespace will be visualized by a small dot.

set-indent-spaces [BOOLEAN enable]

If enabled, the editor will indent with indent-width spaces for each indentation level, rather than with one TAB character.

set-mixed-indent [BOOLEAN enable]

If enabled, kate will use a mix of TAB and spaces for indentation. Each indentation level will be indent-width wide, and more indentation levels will be optimized to use as many TAB characters as possible.

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 tab-width for the document at the time of execution.

set-word-wrap [BOOLEAN enable]

Enables dynamic word wrap according to enable

set-replace-tabs-save [BOOLEAN enable ]

When enabled, tabs will be replaced with whitespaces whenever the document is saved.

set-remove-trailing-space-save [BOOLEAN enable]

When enabled, trailing space will be removed from each line whenever the document is saved.

set-indent-mode [name]

Sets the autoindentation mode to name. If name is not known, the mode is set to 'none'. Valid modes are 'cstyle', 'csands', 'xml', 'python', 'varindent' and 'none'.

set-highlight [highlight]

Sets the syntax highlighting system for the document. The argument must be a valid highlight name, as seen in the Tools->Highlighting menu. This command provides an autocompletion list for its argument.

Commands for editing

These commands modify the current document.

indent

Indents the selected lines or the current line.

unindent

Unindents the selected lines or current line.

cleanindent

Cleans up the indentation of the selected lines or current line according to the indentation settings in the document.

comment

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.

uncomment

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.

kill-line

Deletes the current line.

replace [pattern] [replacement]

Replaces text matching pattern with replacement. If you want to include whitespace in the pattern, you must quote both the pattern and replacement with single or double quotes. If the arguments are unquoted, the first word is used as pattern and the rest for replacement. If replacement is empty, each occurrence of pattern is removed.

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 replace:options pattern replacement. Available options are:

b

Search backwards.

c

Search from cursor position.

e

Search in the selection only.

r

Do regular expression search. If set, you may use \N where N is a number to represent captures in the replacement string.

s

Do case sensitive search.

p

Prompt for permission to replace the next occurence.

w

Match whole words only.

date [format]

Inserts a date/time string as defined by the specified format, or the format “yyyy-MM-dd hh:mm:ss” if none is specified. The following translations are done when interpreting format:

dThe day as number without a leading zero (1-31).
ddThe day as number with a leading zero (01-31).
dddThe abbreviated localized day name (e.g. 'Mon'..'Sun').
ddddThe long localized day name (e.g. 'Monday'..'Sunday').
MThe month as number without a leading zero (1-12).
MMThe month as number with a leading zero (01-12).
MMMThe abbreviated localized month name (e.g. 'Jan'..'Dec').
yyThe year as two digit number (00-99).
yyyyThe year as four digit number (1752-8000).
hThe hour without a leading zero (0..23 or 1..12 if AM/PM display).
hhThe hour with a leading zero (00..23 or 01..12 if AM/PM display).
mThe minute without a leading zero (0..59).
mmThe minute with a leading zero (00..59).
sThe second without a leading zero (0..59).
ssThe second with a leading zero (00..59).
zThe milliseconds without leading zeroes (0..999).
zzzThe milliseconds with leading zeroes (000..999).
APUse AM/PM display. AP will be replaced by either "AM" or "PM".
apUse am/pm display. ap will be replaced by either "am" or "pm".

char [identifier]

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 char: [number] in the entry box, then hit OK.

Example 6.1. char examples

Input: char:234

Output: ê

Input: char:0x1234

Output:

s///[ig] and %s///[ig]

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

In short, Kate searches for text matching the search pattern (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 slash. Parenthesis in the search pattern create back references, that is the command remembers which part of the text matched in the parenthesis. These strings can be reused in the replace pattern, referred to as \1 for the first set of parenthesis, \2 for the second and so on.

To search for a literal ( or ), you need to escape it using a backslash character: \(, \)

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

Example 6.2. Replacing text in the current line

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

"Buckle!" you think, it is of course MyClass. You go to line 3902, and instead of trying to find the word in the text, you launch the Editing Command Dialog, enter s/myclass/MyClass/i, hit the OK button, save the file and compile successfully without the error.

Example 6.3. Replacing text in the whole file

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

Enter the command line and issue the command %s/Miss Jensen/Ms. Jones/ and hit enter, you are done.

Commands for navigation

goto [INT line]

This command navigates to the specified line.

find [pattern]

This command navigates to the first occurrence of pattern according to the configuration. Following occurrences can be found using Edit->Find Next (the default shortcut is F3).

The find command can be configured by appending a colon followed by one or more options, the form is find:options pattern. The following options are supported:

b

Search backwards.

c

Search from cursor position.

e

Search in the selection only.

r

Do regular expression search.

s

Do case sensitive search.

w

Match whole words only.

ifind [pattern]

This command provides “incremental (as-you-type)” searching. You can configure the behavior of the search by appending a colon followed by one or more options, like this: ifind:options pattern. Allowed options are:

b

Search backwards.

r

Do regular expression search.

s

Do case sensitive search.

c

Search from cursor position.

Prev
Next
Home


Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team