When writing Greek, sigmas at the ends of words should have a different form. Can I do something automatically to replace: μῖσοσ by μῖσος, and so in all such cases?

  • 1
    How about running %s/σ\>/ς/g whenever you save the file?
    – muru
    Nov 13 '15 at 17:58
  • Yes, but it would be better to have it corrected straight away.
    – Toothrot
    Nov 13 '15 at 18:09
  • 1
    It's even better to write it correctly from the start :P You could use (greek) dictionary-based autocompletion
    – VanLaser
    Nov 13 '15 at 18:10
  • 2
    The problem is distinguishing an end-of-word sigma from a normal one. I think you'll have to content yourself with typing some other key combination at the end of word (say inoremap σ<spac> ς), then any sigma followed by space will be replaced by the other form. But then you'd have to add another space manually.
    – muru
    Nov 13 '15 at 18:16

Since a final sigma is quickly followed with a space even if a punctuation marks immediately followf it (except for the end-of-line case), you could do this: define the folowwing function (in your ~/.vimrc file) and remap the space key in insert mode to this function.

" The function checks whether a final greek sigma to be fixed can be found
" on the same line at the left of the cursor; the function should be accessed
" through a mapping of the space key in insert mode (since even punctuation
" marks are flollowed with a space.
function! FixPreviousSigma()
    let l:l = line(".")
    let l:c = col(".")
    let l:s = search('σ\>', 'bcW', l:l)
    if l:s == l:l
        silent execute "normal rς"
    call cursor(l:l, l:c)

Then use the tricky mapping whenever you need to use this feature:

:inoremap <Space> <ESC>:call FixPreviousSigma()<CR>a<C-v><Space>

If you also want to take into account the end-of-line case, maybe you could also try:

:inoremap <Enter> <ESC>:callFixPreviousSigma()<CR>o

A little late to the party but literally my solution has to do with a patch of vim from the last week.Due to some case folding issues vim spell checker was handling all final ς as σ.Now you can normally spellcheck greek words (if you build the latest vim from source at least at patch 8.2.2974). So here is a guide for that and a good greek dictionary: Run from wherever

  1. mkdir ~/example_spell
  2. cd ~/example_spell
  3. wget https://raw.githubusercontent.com/wooorm/dictionaries/main/dictionaries/el/index.dic
  4. wget https://raw.githubusercontent.com/wooorm/dictionaries/main/dictionaries/el/index.aff
  5. vim
  6. in vim command mode type :mkspell el2 ~/example_spell/index
  7. then exit vim and type : mkdir ~/.vim/spell
  8. cp -r ~/example_spell ~/.vim/spell

Lastly on your file of interest in vim :set spell spelllang=el2 And z= over greek words.

All of that thanks to Bram Moolenaar taking the time to learn a greek syntax rule just for the sake of good software


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.