Let's say I've got the following function :
function! SomeFunction()
return "/tmp/foo"
endfunction
- If I type :
:echo SomeFunction()
The function is evaluated and the output in vim is the string "/tmp/foo"
.
- If I type :
:edit SomeFunction()
The function is not evaluated, instead of opening the file /tmp/foo
a buffer called SomeFunction()
is opened.
- If I type
!cat SomeFunction()
, the function is not evaluated, the shell complains with the error :
zsh: parse error near `()'
shell returned 1
If I type
execute "!cat " . SomeFunction()
, the function is evaluated and the content of/tmp/foo
is displayed in the shell.If I'm editing the file
foo
which contains the texthello world
and I type!cat %
,%
is evaluated (or expanded ?) and the shell displayshello world
.
I'm a little confused by all those differences.
In which context is a function or a special character like %
(current file) and #
(alternate file) automatically evaluated / expanded and why ?