Closed mroavi closed 4 years ago
Is this possible to do at the current moment?
It's not. Path to selected file is written on exiting vifm, which makes it problematic to select a file without restarting vifm. I've tried running this in vifm:
:!vim --servername $VIM_SERVERNAME --remote +'windo l' %c
but it doesn't open file where I'd expect.
I managed to open something in the right with
:!vim --servername NEW --remote-tab-silent %f &
but it completely messed up vifm.
If opening it in a tab will do, then use that. For me it looks like Vim behaves weirdly, the buffer appears empty until I enter insert mode in it.
I've spent a few more hours on this issue but I still haven't managed to make it work. I tried to use the info on this link to see if I could open files using vifm in an adjacent tmux pane. Also no luck. Do you think this could work with this approach?
I also have another idea: would it be possible to open a file using vifm not in the current but in the other pane?
if I could open files using vifm in an adjacent tmux pane. Also no luck. Do you think this could work with this approach?
Were you trying to do this from a :Vifm
window? Vifm run like that acts differently as it's in a "file-picking mode". Since you don't need it to pick a single file anyway, you should run it using :term vifm
. Otherwise, it should work. If it doesn't, explain what goes wrong.
I also have another idea: would it be possible to open a file using vifm not in the current but in the other pane?
If you want Vim to run inside vifm's pane, then it's not possible. There is no builtin terminal.
I finally managed to get it working with vim's client-server functionality. Here is how in case anybody is interested:
$ vim --servername svim
:!vim --servername svim --remote-tab %f
enter
in your vifmrc file to run this command by default:
nnoremap <cr> :!vim --servername svim --remote-tab %f<cr>
Works amazing.
I made a story in Medium out of this: https://medium.com/@mroavi/my-vim-based-ide-d8524bd0147c?sk=c225ec064ca14f0e327a1bbbaad3a40e
I'm really happy using vifm as my file selector instead of NERDTree, which is also nice, but not as powerful. There is one functionality that I miss though. I would like vifm to stay open after opening a file (with the enter key) using the vifm file selector. I'm opening the vifm file selector using
:leftabove vertical 40Vifm
. This means that I should also be able to switch focus between the vifm file selector and the opened file. Is this possible to do at the current moment?