source: trunk/j/doc/modes.html @ 2

Last change on this file since 2 was 2, checked in by piso, 18 years ago

Initial checkin.

File size: 3.3 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2
3<html>
4
5<head>
6<title>J User's Guide - Modes</title>
7<LINK REL="stylesheet" HREF="j.css" TYPE="text/css">
8</head>
9
10<body>
11
12<a href="contents.html">Top</a>
13
14<hr>
15
16<h1>Modes</h1>
17
18<hr>
19
20<p>
21J provides specialized modes for editing particular kinds of files. Currently
22Java, JavaScript, C, C++, XML, HTML, Lisp, Perl, shell script, makefile,
23autoconf, and properties modes are provided, as well as plain text mode for
24text files that don't fit into any of those categories. There are also modes
25for directory, archive and image buffers.  In addition, any kind of file can be
26viewed (but not edited) in binary mode.
27<p>
28In principle, each mode provides its own implementation of syntax highlighting,
29tagging and indentation, each mode provides its own local key map and menu, and
30each mode supplies its own default values for such properties as tab width,
31indent size, and wrap column.  In the current implementation, C, C++ and
32JavaScript modes inherit much of their functionality from Java mode.
33<p>
34When a file is first opened, j does its best to detect what kind of file it is
35and open it using the appropriate mode. Except for archives and image files,
36binary files are always opened in binary mode.
37<p>
38J uses regular expressions to determine what mode to use based on the name of
39the file. These are j's internal defaults:
40<pre>
41    JavaMode.files=".+\\.java|.+\\.jad"
42    JavaScriptMode.files=".+\\.js"
43    CMode.files=".+\\.c"
44    CppMode.files="(.+\\.cpp)|(.+\\.hpp)|(.+\\.h)"
45    XmlMode.files=".+\\.x[ms]l"
46    HtmlMode.files=".+\\.html?"
47    LispMode.files=".+\\.[ej]l|.*\\.emacs"
48    PerlMode.files=".+\\.p[lm]"
49    ShellScriptMode.files=".+\\.[ck]?sh"
50    MakefileMode.files="makefile(\\.in)?"
51    AutoconfMode.files="configure.in|aclocal.m4"
52    PropertiesMode.files="(.+\\.config)|(.+\\.co?nf)|(.+\\.cfg)|(.+\\.ini)|(.+\\.properties)|prefs"
53    ImageMode.files=".+\\.gif|.+\\.jpe?g|.+\\.png"
54</pre>
55In the current implementation, case is ignored. Note that by default, .h
56files are opened in C++ mode rather than C mode.
57<p>
58You can customize this behavior by supplying different values for these
59regular expressions in your <a href="preferences.html">preferences</a> file.
60<p>
61If the filename doesn't match any of these regular expressions, j examines the
62first line of the file.  If the line begins with "#!", the file is loaded
63in Perl mode or shell script mode, if appropriate.
64<p>
65If the filename doesn't match any of these regular expressions, j defaults
66to plain text mode, so it's not necessary or useful to assign a regular
67expression for plain text mode.
68<p>
69You can use the Properties dialog to change the mode and mode-specific
70properties of the current buffer. The Properties dialog is available on the
71File menu and is mapped by default to Alt P. J makes an effort to remember any
72changes you make in the Properties dialog in case you load the same file again.
73<p>
74You can specify default values for mode-specific properties in your preferences
75file.  You can specify global defaults and override them for specific modes,
76like this:
77<pre>
78    #Global defaults
79    tabWidth=4
80    indentSize=2
81
82    # Override for C++ mode.
83    CppMode.tabWidth=4
84    CppMode.indentBeforeBrace=true
85    CppMode.indentAfterBrace=false
86
87    # Override for Java mode.
88    JavaMode.indentSize=2
89</pre>
90</body>
91
92</html>
93
Note: See TracBrowser for help on using the repository browser.