Vim and Inform 7

These are hints for using Vim to edit Inform7 story files. These all work on a Windows Vim7 installation, but may work on others too.


User isd in the Interactive Fiction Usenet group wrote an Autohotkey script that will navigate to the Inform7 IDE and refresh the story file that you may have been editing in Vim. Once loaded, the default hotkey is right-shift+i - but you can change it to whatever you like.

Download the script here.

Editing your vimrc file

Your vimrc file is your Vim settings file. On Windows, mine is at C:\Documents and Settings\lesliev_vimrc, but can just as easily be edited by going to Edit->Startup Settings in Vim's menu.

On Linux I usually edit the system-wide config file at /etc/vim/vimrc, otherwise you can create a personal vimrc in ~/.vimrc

Getting rid of the ^M ^M ^M's

Edit your vimrc and add these:

filetype on
set fileformats=mac,dos,unix

Vim uses Mac style line endings, which terminates each line with 0x0D characters. The fileformats setting enables the mac format, which Vim should then autodetect in files that you open. You can query the current setting in Vim with :set fileformats?.

If Vim does not autodetect the format, the file is usually broken and you're not going to have much luck until you fix it. I have at least once seen an Inform file that had a 0x0A character right at the end, and when I tried to manually change to mac format (:set ff=mac), the ^M's just changed to ^J's. The only fix I could find for that file was to open it in a hex editor and remove the 0x0A character.

Getting syntax highlighting

Perhaps also check my Github repo for the latest version.

On a Windows installation, the directory is at c:\program files\vim\vim70\syntax. On Linux, man vim should tell you all the paths.

syntax on
" Inform7
au BufNewFile,BufRead *.ni      setf inform7 
SynMenu HIJK.Inform7:inform7

Update, version 2.0!

I made some improvements to this file in April 2011. And then I made improvements to those improvements (on April 18). I have added a command to automatically resync the code folding when the user leaves insert mode. This seems to solve all the remaining code folding problems.

Resyncing works well on my computer (and my very small projects) but if you have a slower system or large projects you might experience speed issues. If you do, disable the automatic sync by editing the file and removing the "au" command near the end. You'll then occasionally have to resync manually.





This is the website of Leslie Viljoen. More info

This website is powered by Rails 4
log in