Well, forgive me for answering twice, but since my first attempt skipped this point, I will have one more step. This is harder than I thought, but maybe not as hard as I did it (!).
Now it's a change to offer all the relevant variable names.
, 'mCC' 'myCamelCase':
function! Camel_Initials(camel)
let first_char = matchstr(a:camel,"^.")
let other_char = substitute(a:camel,"\\U","","g")
return first_char . other_char
endfunction
, ( "mCC" ) ( ) "", . :
function! Expand_Camel_Initials(abbrev)
let winview=winsaveview()
let candidate=a:abbrev
let matches=[]
try
let resline = line(".")
while resline >= 1
let sstr = '\<' . matchstr(a:abbrev,"^.") . '[a-zA-Z]*\>'
keepjumps let resline=search(sstr,"bW")
let candidate=expand("<cword>")
if candidate != a:abbrev && Camel_Initials(candidate) == a:abbrev
call add( matches, candidate )
endif
endwhile
finally
call winrestview(winview)
if len(matches) == 0
echo "No expansion found"
endif
return sort(candidate)
endtry
endfunction
, , , :
function! Camel_Complete( findstart, base )
if a:findstart
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] =~ '[A-Za-z_]'
let start -= 1
endwhile
return start
else
return Expand_Camel_Initials( a:base )
endif
endfunction
, "completefunc":
setlocal completefunc=Camel_Complete
, CTRL-X CTRL-U, CTRL-L:
inoremap <c-l> <c-x><c-u>
vimrc , mCC, CTRL-L, . , .
, , . , . , - .