SIMION®
The field and particle trajectory simulator
Industry standard charged particle optics software
Refine your design: model > simulate > view > analyze > program > optimize it.
SIMION v8.1.3.0-TEST posted.
About | Documentation | Community/Support | Downloads | Ordering

Editing SIMION Text Files

--Instructions on setting up the VIM and Emacs text editors to effectively edit SIMION SL, PRG, and GEM files (e.g. syntax highlighting).

Introduction

This document describes how to configure the VIM and Emacs (XEmacs and GNU) text editors to syntax highlight and perform other functions on SIMION-related files. Below is an example of VIM editing a SIMION "GEM" geometry file:

Although you could edit files in Windows Notepad or use the antiquated SIMION "EDY" editor, an alternate text editor offers the following benefits:

  • Syntax highlighting for improved code readability and making certain errors (e.g. misspelled keywords) instantly visible.
  • Invoking the SL compiler directly from the editor.
  • Displaying line numbers to locate reported errors.
  • Extensive text editing capabilities.

We'll first describe how to configure VIM and then do the same for Emacs.

Downloading

The "Editor Files for SIMION" contain customization files for the VIM and Emacs text editors. The files may be downloaded here: simion-editor.zip (version 2004-04-17).

The VIM Editor - Installation

The steps for setting up VIM to work with SIMION files are provided below:

  • Download and Install VIM for Windows. This can be downloaded from http://www.vim.org by clicking the "Download" link and choosing the "Self-installing executable for MS-Windows" (e.g. "gvim##.exe").
  • Download the Editor Files for SIMION and uncompress it into a temporary directory. These files can be downloaded here: simion-editor.zip.
  • Copy the contained "vimfiles" directory into your Windows profile directory. For example, if your Windows username is "me", your profile directory will likely be "c:\Documents and Settings\me". Therefore, there will be a new directory "c:\Documents and Settings\me\vimfiles".
  • In Windows Explorer, open up any SIMION GEM, PRG, or SL file by right clicking on the file and selecting "Edit with Vim."
  • Enable syntax highlighting. If the text does not appear syntax highlighted (i.e. colored words), select the "Syntax Automatic" menu item to enable this. To make this setting permanent, add the line "syntax enable" to your "c:\Documents and Settings\me\.vimrc" file (and creating this file if it doesn't exist).

The VIM Editor - Optional Tweaks

Here some optional customizations you might want to make.

  • Setting "Easy Mode."

    The first thing you should know about VIM is that VIM is what is called a "modal" editor (in contrast to "modeless" editors like Notepad, MS Word, and Emacs). Read the VIM documentation. If you don't, you will be confused.

    If you don't want to read the manual, or if you prefer the "normal" way to edit text, there is an easy fix. Just add the line "source $VIMRUNTIME/evim.vim" to your ".vimrc" file. VIM will then start up in "Easy Mode," which behaves quite normally.

  • Make VIM your default editor for SIMION. By default, SIMION opens the "EDY" text editor to edit files. EDY is, well, archaic. To make SIMION use VIM, you need to set a few environment variables. Assuming VIM has been installed into the "c:\vim\vim62" directory, the environment variables should be set to
    GUI_EDITOR=c:\vim\vim62\gvim.exe
    GUI_FILENAMES=LONG_FILENAMES

    Under modern versions of Windows, environment variables can be set from the "Windows Control Panel | System | Advanced | Environment Variables." Alternately, if you are starting SIMION from simion.bat, you can add the following lines to the top of the simion.bat file:

    set GUI_EDITOR=c:\vim\vim62\gvim.exe
    set GUI_FILENAMES=LONG_FILENAMES
  • Change the color scheme. The color scheme can be changed from the "Edit | Color Scheme" menu. To make the color scheme permanent add something like "colorscheme desert" to your ".vimrc" file.
  • Compile SL files to PRG code directly in VIM. Open the "c:\Documents and Settings\me\vimfiles\compiler\simsl.vim" file and, if needed, edit the following line:
    setlocal makeprg=c:\\sim7\\sl\\bin\\sl.bat\ %

    to match the location where the SL compiler is installed.

    Now to compile an SL file, first open the SL file. Set the compiler with the command ":compiler simsl". Then execute the command ":make". If there is an error (absent "success" message), you can view the error with ":clist!".

  • Use *.gemh files. A *.gemh file can be run through a C preprocessor to generate a *.gem file. *.gemh files are also properly syntax highlighted. Refer to the simhfn.vim file for details.

The Emacs Editor - Installation

Now, we'll look at how to configure Emacs. Below is a screenshot of XEmacs editing an SL program:

The steps for setting up Emacs to work with SIMION files are provided below:

  • Download and install Emacs for Windows. - The two flavors are XEmacs (http://www.xemacs.org/) and GNU Emacs (http://www.gnu.org/software/emacs/windows/). If in doubt, the author recommends XEmacs.
  • Download the Editor Files for SIMION and uncompress it into a temporary directory. These files can be downloaded here: simion-editor.zip.
  • Install the editor files into Emacs.

    Under XEmacs, copy the files contained in the "emacs" directory into some place where XEmacs can find them (e.g. "c:\Documents and Settings\me\.xemacs"). Then add the following lines to your "c:\Documents and Settings\me\.xemacs\init.el" file:

    (add-to-list 'load-path (expand-file-name "~/.xemacs"))
    (require 'simsl-mode)
    (require 'simprg-mode)
    (require 'simgem-mode)

    Under GNU Emacs, copy the files contained in the "emacs" directory into some directory where Emacs can find them--for example, any directory reported when you run the command M-":" load-path (i.e. ESC key, followed by ":" key, followed by "load-path"). The "c:\", Emacs "site-lib" subdirectory, or a directory named in a HOME environment variable will often do. Then add the following lines to your ".emacs" or "_emacs" file:

    (require 'simsl-mode)
    (require 'simprg-mode)
    (require 'simgem-mode)
    (global-font-lock-mode t)

    The .emacs or _emacs file should be located wherever your HOME directory is (or "c:\" if the HOME environment variable is not set).

The Emacs Editor - Optional Tweaks

Here some optional customizations you might want to make.

  • Make Emacs your default editor for SIMION. To make SIMION use Emacs, you need to set a few environment variables. Assuming Emacs has been installed into the "c:\Program Files\xemacs\i586-pc-win32" directory, the environment variables should be set to
    GUI_EDITOR=c:\Program Files\xemacs\i586-pc-win32\xemacs.exe
    GUI_FILENAMES=LONG_FILENAMES

    Under modern versions of Windows, environment variables can be set from the "Windows Control Panel, System | Advanced | Environment Variables." Alternately, if you are starting SIMION from simion.bat, you can add the following lines to the top of the simion.bat file:

    set GUI_EDITOR=c:\Program Files\xemacs\i586-pc-win32\xemacs.exe
    set GUI_FILENAMES=LONG_FILENAMES
  • Compile SL files to PRG code directly in Emacs. The SL compiler could be invoked via the M-X compile command in Emacs.

Conclusion

The manner to configure the VIM and Emacs text editors to syntax highlight and edit SIMION-related text files has been discussed. Similar methods could be used when setting up other text editors.


Special thanks is given to Robert Malek, who developed the VIM plugins.

--David Manura, Scientific Instrument Services, Inc. 2004-04.

Any comments on this web page? (will be sent to SIS SIMION Support)
[Optional] Your name: email: phone/fax: