# The Fundamentals

If you have ever used a text editor, you will have no problem using &kate;. In the next two sections, Starting &kate; and in Working with &kate;, we'll show you everything you need to get up and running quickly.

## Starting &kate;

You can start &kate; from the &kmenu; or from the command line.

### From the Menu

Open the &kde; program menu by clicking on the big K icon on the toolbar at the bottom left of your screen. This will raise a menu. Move your cursor up the menu to the Applications Utilities Advanced Text Editor &kate; menu item.

### From the Command Line

You can start &kate; by typing its name on the command line. If you give it a file name, as in the example below, it will open or create that file.

    %kate myfile.txt

If you have an active connection, and permission, you can take advantage of &kde;'s network transparency to open files on the internet.

    %kate ftp://ftp.kde.org/pub/kde/README

#### Command Line Options

&kate; accepts following command line options:

``kate` `--help``

- This lists the most basic options available at the command line.

``kate` `--help-qt``

- This lists the options available for changing the way &kate; interacts with &Qt;.

``kate` `--help-kde``

- This lists the options available for changing the way &kate; interacts with &kde;.

``kate` `-s` `--start` `name``

- Starts kate with the session `name`. The session is created if it does not exist already. If a &kate; instance running the specified session exists, the specified files are loaded in that instance. When used with the `--use` option, an instance running this session will be used as well.

``kate` `-u` `--use` `URL``

- Causes &kate; to use an existing instance if there is one. This is now the default behavior, but this option remains for compatibility.

``kate` `-p` `--pid` `PID``

- Only reuses an instance with the specified PID (Process ID). Used with the `--use` option.

``kate` `-e` `--encoding` `encoding` `URL``

- Uses the specified encoding for the document.

``kate` `-l` `--line` `line` `URL``

- Navigates to the specified line after opening the document.

``kate` `-c` `--column` `column` `URL``

- Navigates to the specified column after opening the document.

``kate` `-i` `--stdin``

- Reads the document content from STDIN. This is similar to the common option `-` used in many command line programs, and allows you to pipe command output into &kate;.

``kate` `--startanon``

- Start &kate; with a new anonymous session, implies `-n`.

``kate` `-n` `--new``

- Force start of a new &kate; instance (is ignored if `start` is used and another &kate; instance already has the given session opened), forced if no parameters and no URLs are given at all.

``kate` `-b` `--block``

- If using an already running &kate; instance, block until it exits, if URLs given to open.

  You can use &kate; with this option as editor for typing in commit messages for version control systems like Git or Subversion. These systems expect to block the editor till you have entered your message, because they then open the temporary file, which would be empty if kate immediately returned to the caller.

  This option is also needed with KIO (&kde; Input/Output), if you open a remote file (which has been downloaded to a temporary) and should be reuploaded, after you saved it.

``kate` `--tempfile``

- Since &kate; 2.5.1 this standard &kde; option is supported. When used, the specified files are treated as temporary files and deleted (if they are local files and you have sufficient permissions) when closed, unless they are modified since they were opened.

``kate` `--help-all``

- This lists all of the command line options.

``kate` `--author``

- Lists &kate;'s authors in the terminal window.

``kate` `-v` `--version``

- Lists version information for &Qt;, &kde;, and &kate;.

``kate` `--license``

- Shows license information.

### Drag and Drop

&kate; uses the &kde; Drag and Drop protocol. Files may be dragged and dropped onto &kate; from the Desktop, the filemanager &dolphin; or some remote ftp site opened in one of &dolphin;'s windows.

## Working with &kate;

Quick Start will show you how to toggle four simple options that will let you configure some of &kate;'s more powerful features right away. Shortcuts lays out some of the default keystroke shortcuts for those who can't or don't want to use a mouse.

### Quick Start

This section will describe some of the items on the View menu so that you can quickly configure &kate; to work the way you want it.

When you start &kate; for the first time you'll see two windows with white backgrounds. Above the two windows is a toolbar with the usual labeled icons. And above that, a menubar.

The left-hand window is a side bar. It combines the Documents and Filesystem Browser windows. Switch between the two by clicking on the tabs to the left of the window.

If you've started &kate; with a file, the right-hand window will show the file you are editing and the Documents on the side bar will show the name of the file. Use the Filesystem Browser window to open files.

You can toggle the Documents and Filesystem Browser window on and off in View Tool Views menu. This menu offers you your first glimpse into &kate;'s power and flexibility. In this section we'll look at three items:

Show Documents

- Toggles the Documents on and off. If the Documents/Filesystem Browser window is not open, &kate; launches the side bar as a separate, undocked, window. To dock the window grab the two thin parallel lines above the tabs by clicking on them with your &LMB; and holding the button down. Drag the window into &kate;'s editing window and release the &LMB; when you have positioned the Documents/Filesystem Browser window as you prefer.

  If you have grabbed the two parallel lines successfully your mouse pointer will turn into two crossed arrows as you drag.

Show Filesystem Browser

- Toggles the Filesystem Browser on and off. This menu item is the same as Show Documents with one difference. Toggling it on launches the window with the Filesystem Browser on top.

Show Terminal

- Toggles a terminal emulator on and off at the bottom of &kate;'s window. In other words, it gives you a command line within the application.

### Shortcuts

Many of &kate;'s keystroke commands (shortcuts) are configurable by way of the Settings menu. By default &kate; honors the following key bindings.

Insert | Toggle between Insert and Overwrite mode. When in insert mode the editor will add any typed characters to the text and push any previously typed data to the right of the text cursor. Overwrite mode causes the entry of each character to eliminate the current character.
Left Arrow | Move the cursor one character to the left
Right Arrow | Move the cursor one character to the right
Up Arrow | Move the cursor up one line
Down Arrow | Move the cursor down one line
Page Up | Move the cursor up one page
Page Down | Move the cursor down one page
&Backspace; | Delete the character to the left of the cursor
Home | Move the cursor to the beginning of the line
End | Move the cursor to the end of the line
Delete | Delete the character to the right of the cursor (or any selected text)
&Shift;&Enter; | Insert newline including leading characters of the current line which are not letters or numbers. It is useful ⪚ to write comments in the code: At the end of the line // some text press this shortcut and the next line starts already with // . So you do not have to enter the comment characters at the beginning of each new line with comments.
&Shift;Left Arrow | Mark text one character to the left
&Shift;Right Arrow | Mark text one character to the right
F1 | Help
&Shift;F1 | What's this?
&Ctrl;F | Find
F3 | Find again
&Ctrl;B | Set a Bookmark
&Ctrl;C | Copy the marked text to the clipboard.
&Ctrl;N | New document
&Ctrl;P | Print
&Ctrl;Q | Quit - close active copy of editor
&Ctrl;R | Replace
&Ctrl;S | Save your file.
&Ctrl;V | Paste.
&Ctrl;X | Delete the marked text and copy it to the clipboard.
&Ctrl;Z | Undo
&Ctrl;&Shift;Z | Redo

## Using Sessions

Sessions is how &kate; lets you keep more than one list of files and GUI configuration around. You can have as many named sessions as you want, and you can use unnamed or anonymous sessions for files you want to use only once. Currently &kate; can save the list of open files, and the general window configuration in the session, future versions of &kate; may add more features that can be saved in sessions. With the introduction of sessions, &kate; also allows you to open any number of instances of the application instead of just one as it used to do as the default behavior.

Sessions are supported in three areas:

- Command line options that lets you select and start sessions when launching kate from the command line.

- The Sessions menu that lets you switch, save, start and manage your sessions

- Configuration options that lets you decide how sessions generally should behave.

When starting a new session, the GUI configuration of Default Session is loaded. To save window configuration in the default session, you need to enable saving window configuration in the sessions configuration page of the configuration dialog and then load the default session, set up the window as desired and save the session again.

When a named session is loaded, &kate; will display the session name at the start of the window title, which then have the form "`Session Name`: `Document name or &URL;` - &kate;"

When opening files on the command line with `--start `name`` or if a session is selected using the session chooser, the specified session is loaded prior to the files specified on the command line. To open files from the commandline in a new, unnamed session, configure kate to start a new session as default in the session page of the configuration dialog or use `--start` with an empty string: `''`.

Since &kate; 2.5.1 the PID of the current instance is exported to the environment variable `KATE_PID`. When opening files from the built in terminal Kate will automatically select the current instance if nothing else is indicated on the command line.

### Restoring old style &kate; behavior

When you get used to using sessions you will hopefully see that they provide a very simple and efficient tool for working in different areas. However, if you prefer the old &kate; behavior (one instance opens all files), you can easily achieve that by following this simple strategy:

- Make kate always start with the `--use` parameter by adding that to the command in the application preferences, and additionally using a shell alias.

- Configure &kate; to load the last used session at startup.

- Configure &kate; to save the file list when closing a session.

- Load the default session once

## Getting Help

### With &kate;

This manual

- Offers detailed documentation on all menu commands, configuration options, tools, dialogs, plugins &etc; as well as descriptions of of the &kate; window, the editor and various concepts used in the application.

  Press F1 or use the Help &kate; Handbook menu topic to view this manual.

What's This Help

- What's This help offers immediate help with single elements of graphical windows, such as buttons or other window areas.

  We strive to provide What's This help for any elements for which it makes sense. It is available throughout the configuration dialog, and in many other dialogs as well.

  To employ What's This help, press &Shift;F1 or use the Help What's This menu item to enable What's This mode. The cursor will turn into an arrow with a question mark, and you can now click any element in the window to read the What's This help for that element, if it is available.

Help Buttons in Dialogs

- Some dialogs have a Help Button. Pressing it will start the &khelpcenter; and open the relevant documentation.

### With Your Text Files

&kate; does not (yet!) provide any means for reading document related documentation. Depending on the file you are editing, you may find the Built in Terminal Emulator helpful for viewing related &UNIX; manual pages or info documentation, or you can use &konqueror;.

### Articles on &kate;

&kate;'s homepage provides some Articles and Howtos with further information beyond the scope of this handbook.