Mihail Radu Solcan

  Better integration with Vim of the script for writing Ancient Greek

2008-12-28

In the note on the Vim Toolbar, I have explained how you can add an icon in Vim for the script which converts Betacode to Unicode for Ancient Greek. 

The script converts the content of an entire file. You have to create the Greek text in one file and then paste it into another file. This is not a problem when you work with quotations or larger chunks of Ancient Greek text, but it is annoying to do this for many sparse words in a text. 

Wouldn't be possible to write the Ancient Greek text in Betacode, select it and the convert the selection? The answer is yes. I sketch in this note the method I use in Vim. 

Install vis and cecutil scripts

I will suppose that you work with Vim 7 or a newer version. For older versions you might try to adapt the idea that I am sketching here. 

You have to make sure that your copy of Vim is able to install vimball archives. These explanations on vim.org might help you. Vim 7 and newer comes with the vimball install system already integrated into Vim. 

You need vimball for installing vis.vim, a script created by Charles Cambell. The script makes possible the work with visual selections in Vim. Version 19 uses the vimball system. Download vis.vba.gz and open a terminal. Go to the directory with vis.vba.gz and issue, in the terminal, the command

vim vis.vba.gz

Alternatively, you may extract vis.vba from the archive and open it with vim or gvim. You may even open the archive with gvim directly. In each case, vim will extract vis.vba, the Vimball. 

In vim or gvim, preview the content of the Vimball with:

:VimballList

The Vimball contains two scripts and the relevant documentation. The scripts are vis.vim and cecutil.vim and you need them both. Install with

:so %

Install the script for converting selected Betacode to Unicode

The vis.vim script offers the possibility to work with a visual selection in the following way:Suppose that I select some text (see the image) and I want to change only the letters “s” in the selection with “j”. Select, then press the colon key and then B and write the substitution command. 

vim-agint-subst
Substitute in the selection

The B is one of the two commands made available by vis.vim; I used it in a modified version of the script for writing Ancient Greek text. 

Now, download the scripts contained in the package with the modified version of the conversion from Betacode to Unicode for Ancient Greek. I put b2u.vim in a folder named scripts in the VIMHOME. The ToolBar.vim file contains only the relevant fragment for b2u.vim. For the icon and other details see my note on the Vim Toolbar

Under Windows, you may have to change the file format of the b2u.vim script! I have not tested the script under Windows. It is a plain text file and it should work. The only trouble might arise from the file format. 

How can you change the file format? Use gvim! Go to the menu Edit, then to File Settings, then to File Format; make the relevant changes using the File Format menu. 

Convert selections in Betacode to Unicode for Ancient Greek

As I have already said, I find the idea of working with selections especially attractive when I write single words or short expressions in Ancient Greek. In such a case I do not keep a Betacode source for the quotation or I might not even need to return to Betacode. 

A very good example is the correction of hidden text in DjVu. Let us say that the DjVu file contains OCRed text, but the Ancient Greek text is broken. The OCR has recognized only the English text. We may extract the djvused script, repair it and put the text back in the djvu file. In the image, you can see a portion with broken Greek text and the on-going repair. 

vim-agint-djv
The insertion of Ancient Greek in a djvused script

It is obvious that in the case of the djvused script we have to work with words and short expressions. Under GNU/Linux Fedora 7, it is possible to insert the Greek text directly in Unicode. I have not tested the portability of such a file. I suspect that it is not (very) portable, but I prefer Unicode to the internal DjVu encoding, which is not readable by humans. 

Why not Betacode? DjVu will not recognize words written in Betacode when they include certain special symbols. For example, the backslash will put you in trouble. 

The old scripts

What about the old scripts? You may use them in parallel with the script for selections. Here are the revised versions of the old scripts. 

I suppose that you keep all the scripts in the same folder in VIMHOME. Then pressing the colon key, in normal mode, and

:source ~/.vim/scripts/beta2unicode.vim

will turn the whole file into unicode for Ancient Greek. Return with

:source ~/.vim/scripts/unicode2beta.vim

Read more about these scripts in my note on writing Ancient Greek with Vim