Using variables in a vim shell command

Use the execute command. Everything after it is an expression that evaluates to a string, which it then executes like a command you had typed in yourself.

function Ls(dir)
    execute '!ls ' . a:dir
endfunction

This says, “Evaluate the expression '!ls ' . a:dir and then execute it.” The variable a:dir is expanded, the dot concatenates the two strings into '!ls whatever' and then that is executed as if you had typed it.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)