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?
2 Answers
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ς"
endif
call cursor(l:l, l:c)
endfunction
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
- 448
- 3
- 11
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
mkdir ~/example_spellcd ~/example_spellwget https://raw.githubusercontent.com/wooorm/dictionaries/main/dictionaries/el/index.dicwget https://raw.githubusercontent.com/wooorm/dictionaries/main/dictionaries/el/index.affvim- in vim command mode type
:mkspell el2 ~/example_spell/index - then exit vim and type :
mkdir ~/.vim/spell 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
- 173
- 5
%s/σ\>/ς/gwhenever you save the file? – muru Nov 13 '15 at 17:58inoremap σ<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