[2] | 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> |
---|
| 21 | J provides specialized modes for editing particular kinds of files. Currently |
---|
| 22 | Java, JavaScript, C, C++, XML, HTML, Lisp, Perl, shell script, makefile, |
---|
| 23 | autoconf, and properties modes are provided, as well as plain text mode for |
---|
| 24 | text files that don't fit into any of those categories. There are also modes |
---|
| 25 | for directory, archive and image buffers. In addition, any kind of file can be |
---|
| 26 | viewed (but not edited) in binary mode. |
---|
| 27 | <p> |
---|
| 28 | In principle, each mode provides its own implementation of syntax highlighting, |
---|
| 29 | tagging and indentation, each mode provides its own local key map and menu, and |
---|
| 30 | each mode supplies its own default values for such properties as tab width, |
---|
| 31 | indent size, and wrap column. In the current implementation, C, C++ and |
---|
| 32 | JavaScript modes inherit much of their functionality from Java mode. |
---|
| 33 | <p> |
---|
| 34 | When a file is first opened, j does its best to detect what kind of file it is |
---|
| 35 | and open it using the appropriate mode. Except for archives and image files, |
---|
| 36 | binary files are always opened in binary mode. |
---|
| 37 | <p> |
---|
| 38 | J uses regular expressions to determine what mode to use based on the name of |
---|
| 39 | the 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> |
---|
| 55 | In the current implementation, case is ignored. Note that by default, .h |
---|
| 56 | files are opened in C++ mode rather than C mode. |
---|
| 57 | <p> |
---|
| 58 | You can customize this behavior by supplying different values for these |
---|
| 59 | regular expressions in your <a href="preferences.html">preferences</a> file. |
---|
| 60 | <p> |
---|
| 61 | If the filename doesn't match any of these regular expressions, j examines the |
---|
| 62 | first line of the file. If the line begins with "#!", the file is loaded |
---|
| 63 | in Perl mode or shell script mode, if appropriate. |
---|
| 64 | <p> |
---|
| 65 | If the filename doesn't match any of these regular expressions, j defaults |
---|
| 66 | to plain text mode, so it's not necessary or useful to assign a regular |
---|
| 67 | expression for plain text mode. |
---|
| 68 | <p> |
---|
| 69 | You can use the Properties dialog to change the mode and mode-specific |
---|
| 70 | properties of the current buffer. The Properties dialog is available on the |
---|
| 71 | File menu and is mapped by default to Alt P. J makes an effort to remember any |
---|
| 72 | changes you make in the Properties dialog in case you load the same file again. |
---|
| 73 | <p> |
---|
| 74 | You can specify default values for mode-specific properties in your preferences |
---|
| 75 | file. You can specify global defaults and override them for specific modes, |
---|
| 76 | like 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 | |
---|