Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
+1 vote
in vifm by

I'm using vifm usually in the `only` mode, i.e. without splitting.

However, I have this binding which allows me to press F12 for a quick view of the selected files/dirs.

nnoremap <f12> :if layoutis('only') | vsplit | view! | else | only | endif<cr>

The problem: the pane created with vsplit with the quick view sometimes appears on the left, sometimes on the right. Is it somehow possible to make sure that it is always on the right side?

Probably the key command is `paneisat()`, however, I don't know how to swap the panes if the newly created quick view pane is on the wrong side (left).

1 Answer

0 votes
edited by
Best answer

It's simpler to unconditionally position current pane on the left after the split with Ctrl+W H using :wincmd H (which needs to be wrapped using :execute inside a longer command:

nnoremap <silent> <f12> :if layoutis('only')
                       \|    vsplit
                       \|    execute 'wincmd H'
                       \|    view!
                       \|    only

Thank you, it works!


With `execute 'wincmd H'` the selection jumps to the first line. Is it possible to avoid that somehow?


You mean that the cursor moves to the first entry like on pressing gg? execute 'wincmd H' should not do that. Maybe you have edited the command in some way?


You're right. I had remapped `<C-w>` to some other vifm command. Without remapping the solution above works as expected. Thank you!


Well, thank you for discovering a bug. :wincmd is supposed to be immune to mappings, I'll fix that.

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.

Support Ukraine