# Kon quickstart

Note that all key bindings that are mentioned in this text corresponds to the standard key bindings as configured in the initial installation of Kon. You can easily edit and configure them for your own preferences.

The Kon windows
Editing and navigating in the text
Word wrap
Hex editor
Macro recording
Some not so common features
Search for text
Search and replace text
Unicode

## The Kon windows

The kon window is divided into specific parts:.

- A tabbed control where you edit your text files.
- Optionally a section browser which you use for navigating quickly in the code text.
- A messages window where search results and information about running K-programs is displayed.
- A command prompt where you can enter K-commands.

Kon may contain several text editor windows, but with only one visible at a time. They are then contained within the tab-control.

You can switch between the windows by any of the following methods:

- Left-click on the appropriate tab.
- Right-click on the tab field to popup a menu where you can choose a file.
- Press Alt-PageDown to swith to the next window, or press Alt-PageUp for the previous one.
- Press Ctrl-Tab or Ctrl-Shift-Tab for similar operation.
- Jump directly to a window, by selecting Window from the main menu, and then choose the window you want to jump to.

## Editing and navigating in the text

Kon is inspired by the WordStar word processor, which also many other texteditors have been influenced by. The idea behind the keystrokes used by the WordStar key-bindings is that you should be able to reach all commands from the alpha-numeric keyboard and without having to leave your finger setting.

Not all of the key bindings in WordStar has been implemented, for example the cursor diamond and some keystrokes which conflict with Windows common keystrokes.

Note however, that it is very easy to implement your own keyboard bindings in case you wish to modify the default bindings!

Entering and moving around in the text is straight forward. Kon is by default using "virtual-spaces" which means you can move the cursor beyond line ends. This can be very useful, but can be turned off to implement a more traditional behaviour.

Marking text is done by using the mouse, or by using the shift-cursor keys.

Kon also has a "column-block" mode, where you work with block selections as columns, as opposed to a string of text. This can be very useful when modifying text arranged in columns.

Kon has a mode "persistent blocks" where block marking is not reset when you move the cursor. This can sometimes be useful, but is not set by default.

There is also an undo/redo function. Every change you make to the text can be undone, and redone. The size of the undo buffer is configurable.

## Word wrap

Kon has support for word wrapping in two ways:

- Using soft line breaks. A paragraph is ended by a normal CR+LF (or LF) sequence and linebreaks within the paragraph is represented with a CR+CR+LF sequence. This is the default behaviour, but when saving the file, line ends will be in non-standard format. To avoid this, the line-endings can be removed (which is the usual way this is handled by text-editors) or "finalized" by replacing the soft line breaks with hard line breaks.
- Using hard line breaks. A paragraph is ended by two line breaks in sequence. A "soft" line break is represented by a single line break.

Word wrap settings can be reached from the main menu: Edit->Word wrap.

### Hex editor

The Hex view is useful for editing or viewing binary data. You can modify the binary data as characters, or by modifying the hex code for each character.

The view may also be usable for viewing text-only data as well: Sometimes the textlines may be too long for Kon to handle in the Ascii view. Switching to the Hex view lets you inspect all text in a file. It can also be useful for distincting and replacing for example NULL-characters to spaces, or for inspecting which line ending sequence is used in a file.

You can switch between the Ascii-field and the Hex-field by using the TAB-key, or by simply clicking with the mouse where you want to edit.

Be careful when editing binary data! Kon allows for insertion or deletion of text which may corrupt data, since binary data often is dependent on absolute positions of text in the file.

## Macro recording

The macro recording in Kon is very powerful. The simplest way to use macros is to simply record them by pressing Ctrl-Alt-R (the letter 'R' will be displayed in the status bar to indicate macro recording) and then input the sequence you want to repeat. This may include dialogs: The dialogs wont be displayed at playback, only the results from the dialog interaction will be used. To end the recording, press Ctrl-Alt-R again.

To playback the macro, simply press Ctrl-Alt-P.

The macro itself is a K-program. After the macro is recorded you can edit and execute it in a number of ways.

Apart from saving it to disk, and then include it in a module which is loaded at startup, you can also edit it directly by using the clipboard:

You can copy the recorded macro to the clipboard, paste it in a editor window, edit it, and copy it back to the clipboard. You can then choose to execute the macro from the clipboard. You can of course also write macros directly which you copy to the clipboard and execute from there.

All of these functions can be reached from the main menu: Choose Edit->Macro.

Saving a macro in any of these ways can be a good starting point for writing a small K-program.

## Some not so common features

Kon represents the file internally as a stream of data. This lets you for instance see which byte-position you are standing at in the file: Simply switch to hex view and see where you are positioned. You can also always jump to a specific byte position by pressing Ctrl-p and specify to which position you want to jump.

You can also jump directly to a line by pressing Ctrl-j.

It is possible to show the position in the file relative another position. Pressing Ctrl-p will reset the position indicator in the window's lower left with a zero. Moving backwards will show a negative position relative the position where you pressed Ctrl-p, and positive when moving the cursor after the marked position.

You can store the position you're currently standing at in any of these ways:

- By pressing Ctrl-PageDown your current position will be stored on a stack. Pressing Ctrl-PageUp will restore the latest position from the stack.
- You can store a position in a "slot" numbered from 0 to 9, by pressing Ctrl-K-<slot number>. You retrieve the position in a slot by pressing Ctrl-Q-<slot number>.
- By pressing Ctrl-Space at the places you wish to store, and then press Ctrl-Up or Ctrl-Down to jump between them.

All positions will be marked in the left column of the editor window (if the left margin is set to be visible).

## Searching for text

Kon can search for text in the currently active file, the files opened in the editor, or on files on disk.

For a simple search, just type the text you want to search for in the "Text to find" field, and then press "Search current buffer".

To search in more than one file, select the tab "Multiple files". Then either type the files you want to search (a search pattern works fine. You may separate different files, search patterns using semi-colons.) Also fill in the directory you want to search in or press the "current dir" button.

You can also check "buffers only" and select which opened files you want to search in

For a more comprehensive description of search click here

## Search and replace text

Works very similar to search. Note that replacing in several files on disk is NOT undoable!

For a more comprehensive description of search and replace click here

## Unicode

Internally, Kon works with 8-bit characters. This choice has been made for Kon to work properly as a hex-editor also. Kon does however handle Unicode files to a certain extent. Most Unicode files can be converted into an Ansi equivalent and Kon attempts to do that when a file is loaded. If the content cannot be determined (Unicode files should have a leading byte sequence indicating which type of Unicode the file is encoded with), conversion can be done within the editor (from the "View"-menu, "convert from ..."). When the file later on is saved, it can be saved in Ansi or Unicode. This is specified in the "Save as.." dialog. See also Misc settings

For editing Unicode files with a mix of languages not contained in the default codepage, Kon is probably not the right editor to use, at least not with this version. In time this may change.