Welcome to Vifm Q&A, where you can ask questions about using Vifm. Registration is optional, anonymous posts are moderated. E-mail and GitHub logins are enabled.
0 votes
in vifm by

I'm using the fzf tmux command

But I need to edit the variable string content, inside if statement block, before it's passed to execution command:

\| if $FZF_PICK != ''
\|     execute 'goto' fnameescape($FZF_PICK)
\| endif

how can I achieve that? I've tried with the substitution command to no avail, but that's maybe on me because I'm new to vimscript.

for example, the FZF_PICK variable contains this string:

this/is/my:string:and this is the content

I want to reassign to FZF_PICK all the content up to the first colon sign, effectively removing

:string:and this is the content

from the variable. Then execute the goto command on the (now edited) variable.

1 Answer

0 votes
by

Well, it's not VimScript. Vifm implements only a small subset of that.

You can try appending | cut -f1 -d: after fzf-tmux so that $FZF_PICK will contain only that part of the string.

by
edited by

thank you for clarifying the matter.
Can I apply that edit like this:

\| if $FZF_PICK != ''
\|     let $FZF_PICK = system('echo $FZF_PICK | cut -f1 -d:')
\|     execute 'goto' fnameescape($FZF_PICK)
\| endif

instead of modifying the first assignment?

edit: I just tried, it works

by

On a related edit I'm trying to apply, I would want to change the goto command to edit, and append the line number that's inside a variable, something like that:

execute 'edit +'fnameescape($FZF_LINENUMB) fnameescape($FZF_PICK)

but that's not working
what would be the correct syntax? thank you in advance

edit: found the correct syntax

execute 'edit +$FZF_LINENUMB' fnameescape($FZF_PICK)
If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.
...