vifm / vifm

Vifm is a file manager with curses interface, which provides Vim-like environment for managing objects within file systems, extended with some useful ideas from mutt.
https://vifm.info
GNU General Public License v2.0
2.74k stars 121 forks source link

Alternating between viewers #330

Open j-xella opened 6 years ago

j-xella commented 6 years ago

If I understand it correctly, multiple commands to view files can be specified with :fileview. Also, at the end of the list of available viewers, there is something similar to cat %c added implicitly.

However, only one of the viewers will be used, possibly the first one that returns non-zero output. I was unable to find a way to select an arbitrary viewer, like I can, for example, select a filetype command from the list with :file. It would be nice to be able to alternate between various viewers, if more than one is available.

There could be either additional key bindings for such alternation in "-- VIEW --" mode, or proper command, like mentioned :file, to let user select a viewer from the menu and invoke it.

At the very least, there could be a key binding in the viewer mode to alternate bewteen "formatted" and "as is" modes, as it can be done in midnight commander.

xaizek commented 6 years ago

Also, at the end of the list of available viewers, there is something similar to cat %c added implicitly.

Vifm just reads file on its own or traverses a directory, there is no need to invoke external command (and it actually impedes portability).

However, only one of the viewers will be used, possibly the first one that returns non-zero output.

The first one that is available (first "word" in command is looked up in $PATH).

Do you want to alternate between viewers for a given file or should it be more permanent and somehow preserved when switching to another similar file?

I'm not actually sure how to remember such choice between files as they can be matched by full paths and mime types and thus have different lists of viewers. Except for maybe doing some kind of "pinning" and remembering that if some viewer is in the list for current file, then it should be used (all user's picks could be remembered and checked starting from the most recent pick).

j-xella commented 6 years ago

Honestly, I would say let's keep this simple. The existing logic is pretty good as it is. If a user values one of the viewing methods above others, he should rearrange them accordingly in the vifmrc file.

Otherwise, give the user some commands to quickly switch between viewers, but don't remember the choice when viewing mode -- VIEW -- is exited. I would remember the viewing mode though while viewing is still active, but a different file with the same viewers list is selected, for example if user is browsing through a list of *.xml files in the same folder.

I would imagine the following additions:

  1. :view command would get an additional modifier ? - if set, first user would see a menu similar to :filev, and selected viewer would be applied as an initial choice.
  2. In the -- VIEW -- mode, there are already some commands available, like h j k l q. I would add commands to
    • cycle through the viewers, backward and forward
    • invoke viewers menu and select the one you like (letter m seems to be not used yet...)
    • quickly alternate between currently selected user defined view and the "raw" view, similar to what F8 does in MC viewer.
igorepst commented 4 years ago

Hi, @xaizek. I would like to remind you about this proposal. It would be very useful to have a way to alternate viewers. Thanks!

xaizek commented 4 years ago

Hi. Thanks for reminding. I came to appreciate the need for this, but didn't start implementing it yet.