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.

Is it possible to fall into first folder with files in one single step?

+1 vote
asked Oct 20 in vifm by movEAX

Imagine long path where each folder contains only next nested folder, except last folder, which contains many files. For example:

src/main/java/very/very/long/and/annoyed/package/name

Is it possible somehow to fall from src to name folder in one simple step?

--- Rus ---

В общем, клацкаем по src и вжжжуух и мы уже в name, остальные папки пропускаются т.к. являются лишь вложенными друг в друга. Одной командой это можно сделать? Или опцию какую-нибудь включить?

1 Answer

+1 vote
answered Oct 21 by xaizek

Is it possible somehow to fall from src to name folder in one simple step?

Nope, it would definitely be useful for something like Java projects as you have shown, but there isn't anything like that at the moment. Apart from different way of displaying such directories and slower performance (option can "solve" this), semantics on such directories isn't really clear (how to handle operations on it, how to enter only one level deep, whether to account for filters when evaluating number of files in a directory).

The closest thing now is probably :tree-view, which isn't the same, but might ease navigation.

commented Oct 21 by anonymous

I little bit dig into documentation, and found that I can run user-scripts, so I wrote follow script:

#!/usr/bin/env python3

import os
import sys

cur = sys.argv[1]

for path, dirs, files in os.walk(cur):
    if len(dirs) > 1 or len(files) > 0:
        print(path)
        break
else:
    print(cur)

And put it into ~/.config/vifm/scripts.

After that, I add a new user command:

:com! jmp :execute 'cd' system('cd ~/.config/vifm/scripts && ./dirsjump.py')

And then, map it to <space> (I want ctrl+right, but not found how to do that):

:nmap <space> :jmp<cr>

Seems, all work perfectly. Thank you.

commented Oct 21 by xaizek

Nice workaround. You should be able to simplify the command to

:com! jmp :execute 'cd' system('dirsjump.py')

And might want to account for spaces in path:

:com! jmp :execute "cd '".system('dirsjump.py')."'"

I want ctrl+right, but not found how to do that

Curses doesn't recognize this sequence, so it can be added only by hard coding specific terminal sequences, which might be brittle.

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here won't be considered as spam, but this is not a perfect place for it.
...