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
edited by

If I want vifm to open the config file in a new window how would I do this?
Given these two lines, I'd want the bottom one to behave similarly to the top one.

" Edit vifmrc and apply settings after returning to vifm
nnoremap ,c :write | edit $MYVIFMRC | restart full<cr>

" Edit vifmrc in separate window, apply settings after returning to vifm
nnoremap ,C :write | :execute('foot nvim $MYVIFMRC') | :restart full <cr>

Previously, this used :!gvim with the --remote-tab-silent flag. This allowed for "detatching" the config file for editing while the original window remains in vifm.

Forgive me for the formatting, I am not familliar with how Q2A handles markdown

1 Answer

+1 vote
by
selected by
 
Best answer

Try this:

nnoremap <silent> ,C :write | execute '!foot nvim $MYVIFMRC' | restart full<cr>

execute isn't a function, so no need for parenthesis. It runs command-line command, so you want ! to run an external command. :execute is needed to allow running :restart after a |, otherwise it would be passed to a shell.

by

That's pretty much it!
Is there a way to persist the vifm session to continue browsing/opening files?

Current behaviour:
https://0x0.st/KsBT.mp4

Desired behaviour:
https://0x0.st/KsBU.mp4

The latter uses gvim but essentially I'm trying to get that kind of thing going with nvim and have it reload the config when I close that buffer

by

This may work (sends commands to Vifm after nvim is closed with zero exit code):

let $VIFM_SERVER = v:server
nnoremap <silent> ,C :!foot "nvim $MYVIFMRC && vifm --server-name \"\$VIFM_SERVER\" --remote +write +'restart full'"<cr>

It possibly needs adding bash -c after foot.

by

invalid expression v:server error

by

Right, that should be v:servername.

by

Got this error:

Error: no "view" mailcap rules found for type "inode/x-empty"
Opening "vifm.service" with Neovim  (text/x-dbus-service)
warn: wayland.c:1734: compositor does not implement the XDG toplevel icon protocol
 err: slave.c:508: nvim /home/fugue/.config//vifm/vifmrc && vifm --server-name "$VIFM_SERVER" --remote +write +'restart full': failed to execute: No such file or directory
 err: fdm.c:215: no such FD: 9
Press return ...
by

ah I think I see it

by

nope, thought I knew why .config//vifm/vifmrc was happening but alas I do not

by

Try with bash -c or /bin/bash -c then:

let $VIFM_SERVER = v:server
nnoremap <silent> ,C :!foot bash -c "nvim $MYVIFMRC && vifm --server-name \"\$VIFM_SERVER\" --remote +write +'restart full'"<cr>
by

ah thank you! I was able to do it with this:

nnoremap <silent> ,n :!foot bash -c "nvim $MYVIFMRC && vifm --server-name \"\$VIFM_SERVER\" --remote +write +'restart full'"&<cr>

so the edit window detatches and the original vifm window persists!
https://0x0.st/K-EK.mp4

Thanks again!

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.
...