Skip to content

Instantly share code, notes, and snippets.

@dahu
Created October 23, 2015 10:10
Show Gist options
  • Save dahu/29fab361601fd9f2804c to your computer and use it in GitHub Desktop.
Save dahu/29fab361601fd9f2804c to your computer and use it in GitHub Desktop.
(ab)using the command message window for function signatures
" (ab)using the command message window for function signatures
" Barry Arthur, Oct 2015
function! Signature(msg)
let m = filter(string#scanner(a:msg).split('.\{80}', 1), 'v:val != ""')
let len = len(m)
let msg = join(m, "\n")
let old_cmdheight = &cmdheight
let &cmdheight = len
echo msg
augroup Sig
au!
exe "au InsertLeave * let &cmdheight = " . old_cmdheight
augroup END
endfunction
" Imagine that the following call is made at the time of completion to show the
" signature of the just-expanded function. Due to completion, you would still
" be in insert mode and ready to type... when you leave insert mode, the
" signature is cleared.
call Signature("once a jolly swagman camped by a billabong under the shade of a coolabah tree when down came a jumbuck to drink at that waterhole and up jumped the swagman and grabbed him with glee and he sang you'll come a-waltzing matilda with me oh! waltzing matilda! waltzing matilda! you'll come a-waltzing matilda with me")
$
startinsert
finish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment