Starting with version 0.11.0, j executes the BeanShell script ~/.j/init.bsh (Unix) or C:\.j\init.bsh (Windows) on startup if it exists. This is done after the user's preferences, theme, and custom key maps (if any) have been loaded.
In principle it is possible to execute arbitrary Java code in init.bsh, but only the following commands are officially supported:
void globalMapKey(String keyText, String command) void globalUnmapKey(String keyText) void mapKeyForMode(String keyText, String command, String modeName) void unmapKeyForMode(String keyText, String modeName)You can use these commands to make minor changes to the default key mappings without having to define a full set of custom key maps (see Key Mappings).
For these commands, the keyText
parameter is the name of the key
or key combination to be mapped or unmapped (e.g. "F7", "Ctrl Shift G",
"J"). When in doubt, you can use
insertKeyText to insert the
appropriate text string. The command
parameter is the name of the
command to be mapped (e.g. "openFile", "cyclePaste", "jdkHelp"). The
modeName
parameter is the name of the mode, as displayed in the
status bar when that particular mode is in effect in the current buffer (e.g.
"Java", "HTML", "Plain Text").
Some examples:
globalMapKey("Mouse-1", "mouseSetPoint"); globalUnmapKey("F3"); mapKeyForMode("Alt Mouse-1", "mouseFindTag", "Java"); unmapKeyForMode("F4", "perl");If you make changes to init.bsh while j is running, you can use the command evalBuffer to execute the changed script without restarting j.