Part of setting in my .vimrc.
cat .vimrc
autocmd FileType txt setlocal omnifunc=CompleteMonths
fun! CompleteMonths(findstart, base)
if a:findstart
" locate the start of the word
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] =~ '\a'
let start -= 1
endwhile
return start
else
" find months matching with "a:base"
let res = []
for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")
if m =~ '^' . a:base
call add(res, m)
endif
endfor
return res
endif
endfun
Now edit a test.txt file in vim.
Input J
and press <c-x><c-o>
,why no month complete menu pop up?