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

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, остальные папки пропускаются т.к. являются лишь вложенными друг в друга. Одной командой это можно сделать? Или опцию какую-нибудь включить?

2 Answers

+1 vote
by

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.

by

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.

by

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.

+1 vote
by

If you put the panel into tree mode using :tree command
you will be able search all nested dirs as well entering /yourpattern, since they will be displayed.
you may want to filter out dirs only prior to that

so the commands you may like are:

:filter! /^.*\/$/
:tree

(now you are able to /typeyourstirnghere)

Would it be an option for you?

by

Thanks for reply! Nice suggestion, but solution (python script) from comments of previous answer is more preferable for me.

...