Guides/Syntax Coloring

From J Wiki
Jump to: navigation, search

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.


gedit includes syntax highlighting via GtkSourceView and fairly complete support for J is included since August 2012. The language specification file is available on Github.


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")
augroup filetypedetect
  au! BufRead,BufNewFile *.ijs,*.ijt,*.ijp,*.ijx        setfiletype j
augroup END

Copy the file 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


gtk+ gvim 7.2 using fruidle color scheme on Ubuntu



j-mode edit and run J code with Emacs



Midnight Commander

Copy the file 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


mc 4.6.2-pre1 on xterm



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.


Copy the file 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".


Kate 3.7.2 using KDE 4.7.2 on openSUSE 12.1


Kate with folding

Copy the file File:J13.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".

Folding for indentations and for multiline definitions

starting with: ":\s*0", "define" or "NB.("

and ending with "NB.)" or ")" <on a line alone>

Far Manager

Copy the file File:J.hrc.txt (and rename to j.hrc) to "C:\Program Files\Far Manager\Plugins\FarColorer\base\hrc\auto\types" directory. Insert following lines:

  <prototype name="j" group="main" description="J">
    <location link="types/j.hrc"/>

into "C:\Program Files\Far Manager\Plugins\FarColorer\base\hrc\auto\empty.hrc" file somewhere between "</annotation>" and "</hrc>". Restart Far Manager. Open ijs file for edit.


Far Manager 3.0 on Windows 7


Sublime Text 3

Support for syntax coloring and comment toggling is available for the cross-platform editor Sublime Text from the following Github repository


  • vim vim online

Contributed by Bill Lam Igor Zhuravlov