Vimscript: Sample codes for command completions

Sample Code


" Sample functions {{{
function! Varg(foo)
    "echom a:0
    "echom a:1
    "echom a:2
    echom a:foo
    let cmd_str = "git ls-remote ssh://" . a:foo . " | head -n 10"
    let r = system(cmd_str)
    !echo r

function! Vargs2(foo, ...)
    "echom a:foo
    "echom a:0
    " echom a:1
    echo a:0

function! Assign(foo)
    " let a:foo = "Nope"
    let foo_tmp = a:foo
    let foo_tmp = "Yep"
    echom a:foo
" }}}

com! -complete=custom,ListUserstwo -nargs=1 Sunjoo2 call Varg("")
fun! ListUserstwo(A,L,P)
    return "starfish/build-starfish\nwebos-pro/meta-lg-webos"

Sunjoo2: Command name

call Varg(“”): Vim command triggered when calling a command

ListUserstwo: Function that returns a list of strings for parameter completion


Author: all4dich

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s