The future is coming ready-or-not

Comfortable wiki editing

with one comment

Wikis are great for collaboration, and using your favourite editor makes life more comfortable.  These directions show you how to use Vim on Ubuntu to edit a MoinMoin wiki.

If you spend a lot of time editing a wiki you soon realise that working in a tiny browser text box isn’t that comfortable.  It would be much better if you could use your favourite editor.  That way if Firefox crashes you still have a local copy.  With local editing you can also keep working while the wiki previews your page.  And, re-united with your editor you get to use all those cool productivity-enhancing key combinations that you paid for with serious RSI!

The trick is to use the Firefox add-on It’s All Text! by docwhat. This add-on lets you specify a local editor to use when you edit a textarea.  When you edit a wiki page instead of typing in it you can run your mouse over the bottom of the text area and a small blue “edit” button appears.  If you click this the external editor you specified is launched.

I’m using gvim, so when I click the edit button a gvim window pops up with the mark-up and contents of the wiki page there read for me to edit.  If I save the file then the textarea flashes yellow in my browser as it updates from my gvim window.  When I’ve finished with my page I dismiss the gvim window, preview my page and save.

As Ubuntu uses MoinMoin I wanted to add highlighting so that when I’m editing a wiki page it looks neat and tidy.  Since It’s All Text! provides the buffer as a normal .txt file I needed to tell it how to highlight the MoinMoin file when it loads it.  Here are the steps:

1.  Get the MoinMoin syntax file
There’s a MoinMoin syntax file on Vim Scripts directory so download and save it into ~/.vim/syntax/moin.vim

Just for completeness I’m actually using Gustavo’s moin.vim which is in the latest version of his editmoin. I use a dark background and his highlights are a bit more straightforward.

After you’ve done this you can check it works by saving a MoinMoin wiki page to your system.  Then opening it in vim and running the following command which will show highlights:
:setf moin

2.  Tell vim about locally saved files
Add the following to your ~/.vim/filetype.vim

augroup filetypedetect
au BufNewFile,BufRead *.moin setf moin
au BufNewFile,BufRead *.wiki setf moin
augroup END

This comes from a Wikipedia page on Text editor support when editing Wikipedia.  I believe you only need this step if you’re going to be keeping local copies of your wiki pages as something .moin.  I do this a lot as I like local backups and want to see the highlights when I open them in vim.

At this point you can check it’s working by opening a locally saved MoinMoin page and the highlights should take effect automatically.

3.  Tell It’s All Text! how to launch gvim
Finally, you need to tell the It’s All Text! extension how to launch gvim with the MoinMoin syntax highlighting turned on.  First you need to add a small script somewhere in your path (for me in ~/bin/), it contains:

set -eu
exec /usr/bin/gvim -c “setf moin” “$@”

Just edit the Preferences for It’s All Text! and test it out.  It should launch your gvim window and set the file to being moin so that your highlights are applied.

This is very applicable to other editors, such as Emacs, and perhaps even OpenOffice’ new wiki editor.

The only thing I can’t work out how to do is to apply different settings and highlights depending on which wiki I’m editing.  This is a feature editmoin has that’s pretty useful.



Written by Steve George

February 4, 2009 at 02:36

Posted in Linux, Ubuntu, Web

One Response

Subscribe to comments with RSS.

  1. Thanks – very useful howto.

    In case anyone makes the same mistake I did, the quote marks in the instructions are angled, so if you copy/paste into the script it doesn’t work. Took me a while to figure that one out. 🙂

    Here’s some more MoinMoin related usefulness…




    June 20, 2009 at 02:39

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: