You mean you want to toggle longest
from the 'completeopt'
option?!
You'd have to overwrite the completion triggers, and prepend a no-op :map-expr
to change the option, like this:
function! CompleteoptLongest( isEnable )
set completeopt-=longest
if a:isEnable
set completeopt+=longest
endif
return ''
endfunction
:inoremap <expr> <SID>CompleteoptLongestOn CompleteoptLongest(1)
:inoremap <expr> <SID>CompleteoptLongestOff CompleteoptLongest(0)
:inoremap <script> <C-n> <SID>CompleteoptLongestOn<C-n>
" Repeat for all other completion commands you use...
:inoremap <script> <C-x><C-s> <SID>CompleteoptLongestOff<C-x><C-s>