ChSciTE icon ChSciTE

ChScite in Italy
ChScite in Korea

ChSciTE Documentation

ChSciTE is an Integrated Development Environment (IDE) to edit and run C/Ch/C++ programs in Ch. Ch is an embeddable C/C++ interpreter for cross-platform scripting, shell programming, 2D/3D plotting, numerical computing, and embedded scripting. The user interface of ChSciTE can be in one of over 30 local languages such as German, French, Chinese, Korea, and Japanese.

Getting Started

ChSciTE can be launched by running the command chscite. In Windows, ChSciTE can also be conveniently launched by clicking its icon shown in Figure 1 on a desktop.

ChSciTE icon

Figure 1: A ChSciTE icon on a desktop in Windows

When the ChSciTE is launched, its graphical user interface will appears as in Figure 2. The information as described here will be displayed if clicking Help | ChSciTE Help command.

ChSciTE Help

Figure 2: Get on-line help on how to use ChSciTE.

Editing and Executing C/Ch/C++ Programs

Text editing in ChSciTE works similarly to most Macintosh or Windows editors such as Notepad with the added feature of automatic syntax styling. ChSciTE can hold multiple files in memory at one time but only one file will be visible. ChSciTE allows up to 20 files to be in memory at once. Rectangular regions of text can be selected in ChSciTE by holding down the Alt key on Windows or the Ctrl key on GTK+ while dragging the mouse over the text.

There are two panes in ChSciTE, the editing pane and the output pane. The output pane is located either to the below of the editing pane or on the right. Initially it is of zero size, but it can be made larger by dragging the divider between it and the editing pane.

The Options | Vertical Split command can be used to move the output pane on the right of the editing pane.

With Ch installed on the machine, the edited program can readily be executed in ChSciTE like in other IDE such as Microsoft Visual Studio. The source files are executed interpretively without compilation. The output from the program are directed into the output pane.

The First Example of Editing and Executing a Program with Output.

For example, open a new document, type:

#include <stdio.h> int main() { printf("Hello, world!\n"); return 0; }

as that document's text.

The same program hello.c in CHHOME/demos/bin/hello.c, where CHHOME is the home directory for Ch such as C:/Ch in Windows for C:/Ch/demos/bin/hello.c, can also be loaded using File | Open command.

The program should now appear coloured with syntax highlighting as shown in Figure 3.

Figure 3: Program hello.c

Save the document as hello.c as shown in Figure 4.

Figure 4: Save program hello.c

Perform the Tools | Run as shown in Figure 5 to execute the program hello.c.

Figure 5: Executing program hello.c

Instead of performing the Tools | Run command, pressing function key F5 will have the same effect of executing the program.

The output window will be made visible if it is not already visible and will show:

>ch -u hello.c
Hello, world!
>Exit code: 0
as displayed in Figure 6.

Figure 6: The output from executing program hello.c

The first blue line is from ChSciTE showing the command it will use to run the program. The black line is the output from running the Ch program. The last blue line is from ChSciTE showing that the program has finished and displaying its exit code. An exit code of zero indicates a successful run.

ChSciTE understands the error messages produced by Ch. To see this, add a mistake to the Ch file by changing the line

printf("Hello, world");
printf("Hello, world";
Perform the Tools | Run the modified program. The results should look below

>ch -u hello.c
ERROR: missing ')'
  ERROR: syntax error before or at line 4 in file hello.c
  ==>:    printf("Hello, world\n";
  BUG:    printf("Hello, world\n"; <== ???
ERROR: cannot execute command 'hello.c'
>Exit code: 1
as shown in Figure 7.

Figure 7: The error line in output from executing program hello.c

Click the line in output with red color in Figure 7, the line with incorrect syntax will be highlighted as shown in Figure 8.

Figure 8: Finding the error line in output from executing program hello.c

While it is easy to see where the problem is in this simple case, when a file is larger the Tools | Next Message command can be used to view each of the reported errors. Upon performing Tools | Next Message, the first error message in the output pane and the appropriate line in the editing pane are highlighted with a yellow background, The caret is moved to this line and the pane is scrolled if needed to show the line. ChSciTE now looks like in Figure 8.

ChSciTE understands both the file name and line number parts of error messages in most cases so can open another file (such as a header file) if errors were caused by that file. This feature may not work where the file name is complicated by containing spaces or ".."

If command execution has failed and is taking too long to complete then the Tools | Stop Executing command can be used.

On Windows, ChSciTE defaults to execute tools as command line programs. Executing a GUI program in this mode results in that program being run without displaying a window. The command.subsystem option can be used to define tools that run in GUI mode. The default subsystem, 0, is for command line programs, 1 is for programs which create their own windows, and 2 is for using the ShellExecute call. To run a GUI program such as OpenGL and Windows, use Tools | Launch Ch Shell command to launch a Ch shell. Run the GUI program in this shell.

On GTK+, the default subsystem 0 executes the tool and waits for it to finish, redirecting output to the output pane and subsystem 2 executes the tool in the background.

Setup Paths and Finding Commands in Ch

When a command is typed into a prompt of a command shell for execution, the command shell will search for the command in prespecified directories. In a Ch shell, the system variable _path of string type contains the directories to be searched for the command. Each directory is separated by a semicolon inside the string _path. When a Ch command shell is launched, the system variable _path contains some default search paths. The user can add new directories to the search paths for the command shell by using the string function stradd() which adds arguments of string type and returns it as a new string. For example, the directory C:/Documents and Settings/Administrator/c99 is not in the search paths for a command. If you try to run program hello.c in this directory when the current working directory is C:/Documents and Settings/Administrator. The Ch shell will not be able to find this program as shown below and give two error messages. C:/Documents and Settings/Administrator> hello.c ERROR: variable 'hello.c' not defined ERROR: command 'hello.c' not found When Ch is launched or a Ch program is executed, by default, it will execute the startup file .chrc in Unix or _chrc in Windows in the user's home directory if it exists. In the remaining presentation, it is assumed that Ch is used in Windows with a startup file _chrc in the user's home directory. This startup file typically sets up the search paths for commands, functions, header files, etc. By default, there is no startup file in a user's home directory. The system administrator may add such a startup file in a user's home directory. However, the user can execute Ch with the option -d as follows ch -d to copy a sample startup file from the directory CHHOME/config/ to the user's home directory if there is no startup file in the home directory yet. Note that CHHOME is not the string "CHHOME", instead it uses the file system path under which Ch is installed. For example, by default, Ch is installed in C:/Ch in Windows and /usr/local/ch in Unix. In Windows, the command in a Ch shell below C:/Documents and Settings/Administrator> ch -d will create a starup file _chrc in the user's home directory C:/Documents and Settings/Administrator. This local Ch initialization startup file _chrc can be opened for editing the search paths by ChSciTE editor as shown in Figure 10.

Figure 10: Open the local Ch initialization startup file for editing.

To include the directory C:/Documents and Settings/Administrator/c99 in the search paths for a command, the following statement _path = stradd(_path, "C:/Documents and Settings/Administrator/c99;"); needs to be added to the startup file _chrc in the user's home directory so that the command hello.c in this directory can be invoked regardless of what the current working directory is. After the directory C:/Documents and Settings/Administrator/c99 has been added to the search path, _path, you need to restart a Ch command shell. Then, you will be able to execute the program hello.c in this directory as shown below. C:/Documents and Settings/Administrator> hello.c Hello, world

Similar to _path for commands, the header files in Ch are searched in directories specified in the system variable _ipath. Each path is also delimited by a semicolon. For example, the statement below _ipath = stradd(_ipath, "C:/Documents and Setting/Administrator/c99;"); adds the directory C:/Documents and Setting/Administrator/c99 to the search paths for header files.

One can also add this directory to the function file search paths by the statement

_fpath = stradd(_fpath, "C:/Documents and Setting/Administrator/c99;");

In Unix, the search paths for commands by default do not contain the current working directory. To include the current working directory in the search paths for a command, the following statement _path = stradd(_path, ".;"); in startup file .chrc in the user's home directory needs to be added. Function call stradd(_path, ".;") adds the current directory represented by '.' to the system search paths _path.

The Second Example with Input.

This example will show how to run a C/Ch/C++ program/script that requires the user to input data. Type in the code as shown in Figure 11.

The same program C:/Ch/demos/bin/scanf.c can also be loaded using File | Open command.

During execution, this code should ask the user to "Please input a number" and then cause the system to output "Yout input number is" and the number that the user inputted.

Figure 11: A program with input from the user.

During the execution of the program, the user will be prompted to input a number as shown in Figure 12. The user then must type in a number in the same pane for both input and output. Both input number of 56 and output are shown in Figure 12.

Figure 12: Executing the program with input and output.

The Third Example with Plotting in Ch.

This example will show how to run a C/Ch/C++ program/script that creates a plot using Ch Professional Edition. Type in the code as shown in Figure 13. The same program C:/Ch/demos/bin/fplotxy.cpp as shown in Figure 13 can also be loaded using File | Open command. When the program is executed, it creates a plot shown in Figure 14. The plotting function fplotxy() is available in Ch Professional Edition. The program shown in Figure 13 uses the plotting function fplotxy() to plot function func() with 37 points and with the x value in the range from 0 to 360.

Figure 13: A plotting program using fplotxy().

Figure 14: The output of the plotting program.

The plotting function plotxy() is available to plot data stored in C arrays. The program C:/Ch/demos/bin/fplotxy.cpp shown in Figure 15 uses regular C array to store the data used for plotting. When the program C:/Ch/demos/bin/plotxy.cpp shown in Figure 15 is loaded and executed, it creates the same plot shown in Figure 14.

Figure 15: A plotting program using plotxy().

The plotting function fplotxy() can be used to plot three-dimensional functions with two variables as shown in Figure 16. This program plot function cos(x)sin(y) for the x value in the range from -3 to 3 and y in the range of -4 to 4. The plot uses 80 points for both x and y. When the program C:/Ch/demos/bin/fplotxyz.cpp shown in Figure 16 is loaded and executed, it creates the plot shown in Figure 17.

Figure 16: A plotting program using fplotxyz().

Figure 17: The output of the plotting program using fplotxyz().

Command Parameters and Prompting

ChSciTE has 4 properties $(1) .. $(4) which can be used to run commands with changeable parameters. To set the parameter values, use the View | Parameters command to view the modeless Parameters dialog which shows the current values of these parameters and allows setting new values. The accelerator keys for the main window remain active while this dialog is displayed, so it can be used to rapidly run a command several times with different parameters. Alternatively, a command can be made to display the modal Parameters dialog when executed by starting the command with a '*' which is otherwise ignored. If the modeless Parameters dialog is already visible, then the '*' is ignored.

The Fourth Example with Command Parameters.

This example will show how to run a C/Ch/C++ program/script with command parameters. Type in the code as shown in Figure 18. This program will accept the command parameters and print them out. The parameters are setup in View|Parameters menu as shown in Figure 19 and Figure 20 The output from execution of this program with command parameters is displayed in Figure 21

Figure 18: A program for handling command parameters.

Figure 19: Setup command parameters.

Figure 20: Setup command parameters.

Figure 21: Executing the program with command parameters.


ChSciTE has 20 buffers each containing a file. The Buffers menu can be used to switch between buffers, either by selecting the file name or using the Previous (F6) and Next (Shift+F6) commands.

When all the buffers contain files, then opening a new file causes a buffer to be reused which may require a file to be saved. In this case an alert is displayed to ensure the user wants the file saved.


A session is a list of file names. You can save a complete set of your currently opened buffers as a session for fast batch-loading in the future. Sessions are stored as plain text files with the extension ".ses".

Use File | Load Session and File | Save Session to load/save sessions. You can turn on/off "last session autoloading" using ChSciTE properties variable "save.session".

By default, session management is turned on.

Loading previously saved session will close your currently opened buffers. However you will not loose your edits, because you will be asked to save unsaved buffers first.

Opening a specific file from command line overrides "save.session" variable state. When you start ChSciTE loading a specific file from command line last session will not restore even if "save.session" variable is set to "1". This makes "save.session" safe to use - you will never open a couple of files when you are trying to open just one, specific file.

Languages Understood by ChSciTE

ChSciTE currently is able to syntax style these languages (* denotes support for folding):

  • C/Ch/C++*
  • CSS*
  • HTML*
  • Make
  • SQL and PLSQL
  • TeX and LaTeX
  • XML*

Language settings are determined from the file extension but this can be changed by selecting another language from the Language menu. The language menu can be changed with the menu.language property.

Find and Replace

ChSciTE has options to allow searching for words, regular expressions, matching case, in the reverse direction, wrapping around the end of the document. C style backslash escapes which are listed in the command line arguments section, may be used to search and replace control characters. Replacements can be made individually, over the current selection or over the whole file. When regular expressions are used tagged subexpressions can be used in the replacement text. Regular expressions will not match across a line end.

ChSciTE supports basic regular expressions with tagging.

Keyboard Commands

ChSciTE uses the default key bindings defined in Scintilla, so keyboard commands in ChSciTE mostly follow common Windows and GTK+ conventions. All move keys (arrows, page up/down, home and end) allows to extend or reduce the stream selection when holding the Shift key, and the rectangular selection when holding the Shift and Alt keys. Some keys may not be available with some national keyboards or because they are taken by the system such as by a window manager on GTK+. The user.shortcuts setting may be used to assign a key to a function. Note that Home key behaviour is changed by the vc.home.key option. Keyboard equivalents of menu commands are listed in the menus. Some less common commands with no menu equivalent are:

Run C/Ch/C++ program.F5
Parse C/Ch/C++ program.F7
Launch Ch shell.Ctrl+F7
Magnify text size.Ctrl+Keypad+
Reduce text size.Ctrl+Keypad-
Restore text size to normal.Ctrl+Keypad/
Cycle through recent files.Ctrl+Tab
Indent block.Tab
Dedent block.Shift+Tab
Delete to start of word.Ctrl+BackSpace
Delete to end of word.Ctrl+Delete
Delete to start of line.Ctrl+Shift+BackSpace
Delete to end of line.Ctrl+Shift+Delete
Go to start of document.Ctrl+Home
Extend selection to start of document.Ctrl+Shift+Home
Go to start of display line.Alt+Home
Extend selection to start of display line.Alt+Shift+Home
Go to end of document.Ctrl+End
Extend selection to end of document.Ctrl+Shift+End
Go to end of display line.Alt+End
Extend selection to end of display line.Alt+Shift+End
Expand or contract a fold point.Ctrl+Keypad*
Create or delete a bookmark.Ctrl+F2
Go to next bookmark.F2
Select to next bookmark.Alt+F2
Find selection.Ctrl+F3
Find selection backwards.Ctrl+Shift+F3
Scroll up.Ctrl+Up
Scroll down.Ctrl+Down
Line cut.Ctrl+L
Line copy.Ctrl+Shift+T
Line delete.Ctrl+Shift+L
Line transpose with previous.Ctrl+T
Line duplicate.Ctrl+D
Find matching preprocessor conditional, skipping nested ones.Ctrl+K
Select to matching preprocessor conditional.Ctrl+Shift+K
Find matching preprocessor conditional backwards, skipping nested ones.Ctrl+J
Select to matching preprocessor conditional backwards.Ctrl+Shift+J
Previous paragraph. Shift extends selection.Ctrl+[
Next paragraph. Shift extends selection.Ctrl+]
Previous word. Shift extends selection.Ctrl+Left
Next word. Shift extends selection.Ctrl+Right
Previous word part. Shift extends selectionCtrl+/
Next word part. Shift extends selection.Ctrl+\


To use an abbreviation, type it and use the Expand Abbreviation command or the Ctrl+B key. The abbreviation is replaced by an expansion defined in the Abbreviations file. You can open the Abbreviations file with a command in the Options menu and add abbreviations.

Each line in the files looks like "abbreviation=expansion".
The abbreviations names can have any character (except perhaps control chars, surely for CR and LF), including high Ascii chars (accented chars).
Names have properties files limits: they cannot start with sharp (#) or space or tab (but can have spaces inside); and they cannot have '=' character inside.
Abbreviations names are limited to 32 characters. It is probably enough for abbreviations...

An expansion may contain new line characters indicated by '\n' and a caret position indicated by the '|' character. To include a literal '|' character, use '||'.
Some simple examples are included in the distributed Abbreviations file.
When expanding, the names don't need to be separated from the previous text. i.e. if you define '' as '&eacute;', you can expand it inside a word.
If a name is the ending of another one, only the shorter will ever be expanded. Ie. if you define 'ring' and 'gathering', the later will see only the 'ring' part expanded.


ChSciTE supports folding for many languages (see the list of languages understood by ChSciTE for more information.) Fold points are based upon indentation for C and on counting braces for the other languages. The fold point markers can be clicked to expand and contract folds. Ctrl+Shift+Click in the fold margin will expand or contract all the top level folds. Ctrl+Click on a fold point to toggle it and perform the same operation on all children. Shift+Click on a fold point to show all children.


ChSciTE will automatically detect the encoding scheme used for Unicode files that start with a Byte Order Mark (BOM). The UTF-8 and UCS-2 encodings are recognized including both Little Endian and Big Endian variants of UCS-2.

UTF-8 files will also be recognized when they contain a coding cookie on one of the first two lines. A coding cookie looks similar to "coding: utf-8" ("coding" followed by ':' or '=', optional whitespace, optional quote, "utf-8") and is normally contained in a comment:
# -*- coding: utf-8 -*-
For XML there is a declaration:
<?xml version='1.0' encoding='utf-8'?>

For other encodings set the and character.set properties.