Editors
Editors
Various editors with various tools for programming, such as syntax highlighting, exist. This page lists some examples of editors and how to configure them.
This page is still under construction! If you feel something is missing or should be added please do so by yourself!
EMACS
To run emacs just enter
emacs [-nw]
in a terminal. Usually, this opens a new x-window. If you do not want to have a new window opened, you can run emacs with the -nw option (short for --no-window-system). In this case, the editor will have a simple, but fully functional interface in the terminal.
Keyboard Shortcuts
A list of shortcuts can be found here: [1]
Ctrl+X+C | quit jed |
Ctrl+X+S | save the current buffer into a file |
Ctrl+G | cancel the current operation (e.g., entering commands) |
Ctrl+Space | start/end region selection mode |
Ctrl+W | cut region |
Ctrl+Y | paste region |
Alt+X | enter and execute emacs command(s) |
To set your own keywords you can type following command into you .emacs file:
(global-set-key (kbd "keyword (e.g. f7 or C-c C-i") 'name_of_mode_command)
Loading modes in emacs
Emacs has a lot of built in modes which can be activated with (M=metakey=ALT)
M-x modename
However, sometimes you want to either write you own mode or download one from the Internet. These packages usually have a .el ending and are written in lisp code. To load them you can put them basically in any directory you want. It may be convenient to create a new folder (e.g. ./emacs.d/lisp) in your home directory and load the mode with:
;; Load path for .el modes (setq load-path (append load-path (list "~/.emacs.d/lisp"))) (load "mode_name_without_.el")
If you don't always want to activate it you can activate it already in you .emacs:
(global-mode_name_without_.el t)
Killing and yanking over several files in emacs
Copy - Paste is called kill - yank in emacs. It is done with C-w (M-w for copy) and C-y. If you want to kill and yank over two files you opened with emacs you can use emacsclient [2] .
To enable the Emacs server, add the command
(server-start)
to your init.el. This is a requirement for using the Emacs client! When the server is running, closing the last Emacs frame will leave the server running. To shut Emacs down completely, call the command `(kill-emacs)’.
Open the file with
emacsclient -nw -create-frame --alternate-editor=""
and you'll be able to kill - yank over two (or more) documents.
Folding modes
There are several folding modes that can be loaded with emacs:
- HideShow [3] is a convenient tool that has it's own algorithm to hide certain parts of your code. Invoke HideShow mode with M-x hs-minor-mode.
- Some users may find it more useful to use the {{{ }}} syntax to fold parts of their code instead. This can be done with folding-mode [4]. The folding.el file can be downloaded from the GitHub [5]. Follow the instructions above to load the mode in your .emacs.
Syntax highlighting in s-lang
emacs does not have a build-in syntax highlighting for s-lang (jed does!), but our good friends from MIT have written one: slang-mode.el
Save the file at your preferred path and add the following lines to your .emacs file (that should automatically exist in your home directory).
(load "yourpreferredpath/slang-mode.el") (autoload 'slang-mode "slang-mode" "Mode for editing slang source files") (setq auto-mode-alist (append '(("\\.sl$" . slang-mode)) auto-mode-alist))
JED
In principle, jed is a clone of emacs, written in S-Lang by John E. Davis. To run jed, enter
jed
into a terminal. It is very easy to modify and extend, since you can define and run S-Lang functions to, e.g., apply a certain task to the current region, i.e., marked text.
Keyboard Shortcuts
Most of the emacs shortcuts and |Alt+Shift+X|enter and execute S-Lang command(s)| A list of intrinsic jed functions is found here: http://www.jedsoft.org/jed/doc/jedfuns.html
Note: the keys defining the shortcuts are give in some strange format, like "^X^C" for Ctrl+X+C. The string corresponds to the character send to the terminal. You can find out this string using
sed -n l
in a terminal. Try pressing Ctrl+X+C
Configuration
jed can be configured via the .jedrc file in your home directory, which has to contain S-Lang commands only. Thus, user-defined functions can be implemented here. Customizing jed is controlled by variables. Here is an example of a simple .jedrc:
No_Backups = 1; % create no backups of edited files DISPLAY_TIME = -1; % show time in 24h format in status bar C_BRA_NEWLINE = 0; % 0 / 1 => doesn't start / starts a block in braces on a new line C_BRACE = 0; % amount of space to indent brace C_INDENT = 2; % indentation of blocks HORIZONTAL_PAN = -1; % entire window will pan LINENUMBERS = 2; % show line and column number in status bar WRAP = 1<<31-1; % effectively disables wrapmode WRAP_DEFAULT = 1<<31-1; % effectively disables wrapmode % define additional keybindings setkey("uncomment_region_or_line","^X:"); % define the color scheme to use Color_Scheme_Path += ",/home/you/share/jed/color/"; % path to additional schemes set_color_scheme("white-gm"); % define a useless function and bind it to Alt+1 public define useless() { vmessage("this is useless"); } local_setkey("useless", "^[1");
Color Scheme
In the above example, the user-defined color scheme white-gm is used. This is the S-Lang file white-gm.sl in the Color_Scheme_Path:
% A color scheme for the terminal/console with white background % % Copyright (c) 2003 Günter Milde % Released under the terms of the GNU General Public License (ver. 2 or later) % % This scheme uses only the basic color set, so it should work with all % flavours of jed (tested with jed in rxvt and Linux console). % static variable bg = "white"; set_color("normal", "black", bg); set_color("status", "yellow", "blue"); set_color("region", "yellow", "blue"); set_color("operator", "blue", bg); % +, -, etc.. set_color("number", "blue", bg); % 10, 2.71, etc.. set_color("comment", "magenta", bg);% /* comment */ set_color("string", "blue", bg); % "string" or 'char' set_color("keyword", "blue", bg); % if, while, unsigned, ... set_color("keyword1", "red", bg); % malloc, exit, etc... set_color("delimiter", "blue", bg); % {}[](),.;... set_color("preprocess", "green", bg); set_color("message", "blue", bg); set_color("error", "red", bg); set_color("dollar", "red", bg); set_color("...", "red", bg); % folding indicator set_color ("menu_char", "yellow", "blue"); set_color ("menu", "white", "blue"); set_color ("menu_popup", "white", "blue"); set_color ("menu_shadow", "blue", "black"); set_color ("menu_selection", "white", "cyan");