Sword Module Generator

By: Owen T. Heisler
Updated: 2020-02-01
Published: 2013-01-28

This script converts a dictionary or commentary IMP file to a Sword module.


These steps use “personal commentary” and “personal dictionary” modules as examples, but the steps apply to any other commentary or dictionary also. Note, however, that modules names should not be longer than 15 characters.

  1. Download example source files and add some content:

  2. Install dependencies: python3, libsword-utils (imp2vs and imp2ld)

  3. Download the script: swordmodgen.py

  4. Create directories for generated module files:

    $ mkdir ~/.sword/modules/comments/zcom/personalcomm/
    $ mkdir ~/.sword/modules/lexdict/zld/personaldict/
  5. Generate modules (add the --force option to allow old module files in the destination directory to be replaced on subsequent runs):

    $ swordmodgen.py -c comm.imp ~/.sword/modules/comments/zcom/personalcomm/
    $ swordmodgen.py -d dict.imp ~/.sword/modules/lexdict/zld/personaldict/
  6. Download, edit, and add the Sword configuration files:

Editing the IMP files with Emacs

If you will be editing IMP files with Emacs, the following (added to your ~/.emacs file) will make filling (M-q) work correctly.

(define-derived-mode imp-mode text-mode "IMP"
  "Major mode for editing IMP bible files."
  (setq paragraph-separate "\\([ \t\f]*\\|\\$\\$\\$.*\\)$"))
  (add-to-list 'auto-mode-alist '("\\.imp\\'" . imp-mode))

See also