Most text editors support syntax coloring and since J only has a very small number of syntactic classes, it is very easy to write a specification file for J. Utilities for syntax coloring (aka syntax highlighting) are also becoming more common for displaying code on HTML pages.

Here are some examples of syntax specification files.

Note that some editors support theme so that actual screenshots should be different from what are displayed here.

Vim

This required Vim version 7.0 or above.

If the directory $HOME/.vim/syntax does not exist, create it by typing inside terminal

mkdir -p ~/.vim/syntax

Create or edit the file filetype.vim inside your $HOME/.vim directory, as follows.

" my filetype file
if exists("did_load_filetypes")
  finish
endif
augroup filetypedetect
  au! BufRead,BufNewFile *.ijs,*.ijt,*.ijp,*.ijx        setfiletype j
augroup END

Copy the file j.vim.txt (and rename to j.vim) to your $HOME/.vim/syntax directory.

The name of directory .vim for ms window is vimfiles and $HOME can be found be typing :echo $HOME.

Screenshot: The actual color displayed depends on current color scheme. There are many color schemes inside vim's wikia site. Vim scripts Vim scripts - Vim Tips Wiki - a Wikia wiki

console vim 7.2 using desert256 color scheme on xterm-256 color

vim-dark.png

gtk+ gvim 7.2 using fruidle color scheme on Ubuntu

vim-light.png

Emacs

j-mode edit and run J code with Emacs

Screenshot:

j-mode-screenshot.png

Midnight Commander

Copy the file j.syntax.txt (and rename to j.syntax) to your $HOME/.mc/cedit directory.

Enter menu "Command -> Edit syntax file" and insert following lines:

file ..\*\\.ij[xs]$ J\sFile
include $HOME/.mc/cedit/j.syntax

Screenshot:

mc 4.6.2-pre1 on xterm

mc-screenshot.png

GeSHi

GeSHi (Generic Syntax Highlighter) provides the syntax highlighting on Rosetta Code.

GeSHi development is hosted on SourceForge, where the current GeSHi specification file for J can be found.

The Guides/Syntax Coloring/GeSHi Options page describes some decisions regarding J syntax highlighting in GeSHi that need to be made. Please register your views there or on the forum.

Kate

Copy the file j.xml.txt (and rename to j.xml) to your $HOME/.kde4/share/apps/katepart/syntax directory. Restart Kate editor. Open ijs file or switch to window with J script. Select menu item "Tools -> Highlighting -> Scripts -> J".

Screenshot:

Kate 3.7.2 using KDE 4.7.2 on openSUSE 12.1

Kate-screenshot-conlib.png

References

Contributed by BillLam IgorZhuravlov

Guides/Syntax Coloring (last edited 2012-03-20 23:51:59 by IgorZhuravlov)