On 2024-11-10, avidseeker wrote:
> I have a script that selects templates based on the given filetype and outputs
> them to stdout. For example:
> 
> :.!tplt %:e
> 
> But the %:e is not always reliable. Does vim offer a way to pass variables for
> shell? Maybe something like
> 
> :.!tplt "$ft"

To use the value of an option, prefix the name of the option with
'&', e.g.,

    :echo &ft

The option value &ft has to be expanded and Vim needs to be told to
expand it rather than pass it to the shell command literally.  That
can be be done with the :execute command, which expands its
arguments before executing the resulting expression, e.g.,

    :execute ".!tplt" &ft

Note that the range has to be part of the expression that :execute
executes; the range can't come before "execute".

Note also that :execute inserts spaces between its arguments.

See

    :help expr-option
    :help :execute

HTH,
Gary

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/20241110190206.GL15474%40phoenix.

Raspunde prin e-mail lui