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.

Two equal actions for extensionless files in a particular directory

0 votes
asked Jan 30, 2016 in vifm by aleksejrs
edited Jan 30, 2016 by aleksejrs

What is a good way to execute “:file” (“display menu of programs set for the file type of the current file.”)? Any idea on a standard keyboard shortcut?

I have a directory tree with some files with which I do two things:
1. (on a single file) gvim -O ../known/%c ../unknown/%c ../unneeded/%c
2. (on one, several, or — by default — all files) cd .. && ./do.sh %f:p %m

  • For the first action, I gave the files an extension and made a filextype definition.
  • For the second action, I made a “command!”.

I hope to avoid having to add an extension or type an Ex command.

I added the second action to the filextype definition and added “nnoremap <cr> :file<cr>”. It’s usable, because I usually use l to switch between directories, but is obviously confusing.

commented Feb 6, 2016 by aleksejrs

Hm…

The "echo -n &&" workaround works only with a single file; with multiple files, Vim is started with the files open.

commented Feb 6, 2016 by xaizek

Maybe there are non-*.wdk files in selection?

commented Feb 7, 2016 by aleksejrs

.wdk is not used any more.

`
filetype ///home/user/Documents/wikidata/(known|unknown|unneeded)/.*//

\ {my Wikidata knowledge tool}
\ echo -n && cd .. && ./do.sh %f:p %m,

`

commented Feb 7, 2016 by xaizek

That was a bug with handling path regexps, fixed on latest master (d681808), thanks!

commented Feb 13, 2016 by aleksejrs

Thanks, it works in 0.8.1a.

1 Answer

0 votes
answered Jan 30, 2016 by aleksejrs

Solved for the first action:

autocmd DirEnter ~/Documents/wikidata/*/ nnoremap o :!gvim -O ../known/%c ../unknown/%c ../unneeded/%c<cr>

autocmd DirEnter !~/Documents/wikidata/*/ execute 'nnoremap o :!gvim --remote-tab-silent %f<cr>'

For the second action, I found “//path-regular-expression//[iI]”, so I could define a filetype for all files in those directories. But I can’t find out how to use that or path globs.

commented Jan 31, 2016 by xaizek

For the second action, I found “//path-regular-expression//[iI]”, so I could define a filetype for all files in those directories. But I can’t find out how to use that or path globs.

It's the same, just wrap the pattern with //, a couple of examples:

filextype ///home/xaizek/archive/articles/.*\.pdf// vim
execute 'filextype //'.$HOME.'/archive/articles/.*\.pdf// vim'
commented Feb 1, 2016 by aleksejrs

Thanks. So I tried it correctly at first, but couldn't notice because my command with "cd .. &&" (unlike nano %c) is affected by that Vim-running "interference" above.

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.
...