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.
0 votes
in vifm by

I'd like to achieve following:

  • <CR> - fall through, e.g. open the file or traverse into the directory at hand
  • 4<CR> - jump to file 4

In vim I'm using <expr>:
nnoremap <expr> <silent> <CR> v:count ? ":<C-U><Esc>" . v:count . "G" : "<CR>"

But since vifm doesn't appear to support it, I'm trying to work around it with plain if:
nnoremap <CR> :<C-U>if v:count|exe ':' v:count|else|norm! l|endif<CR>

This works fine until it doesn't: traversing into a directory works fine, whereas jumping to the n-th file seems to work, too, but just once. After that, bindings stop working altogether and I have to kill vifm via C-Z.

Is this a vifm bug? Can I work around it?

1 Answer

0 votes
by
 
Best answer

:normal is in the list of commands that can't be ended with |, you need to use :execute for it as well:

nnoremap <CR> :<C-U>if v:count|exe ':' v:count|else|exe 'norm! l'|endif<CR>

Is this a vifm bug?

:normal ate endif and vifm considered all future :commands to be in part of if-statement that isn't executed. You could also use ZZ or type :endif.

It might be worth thinking about terminating incomplete conditional on leaving command-line mode, this doesn't happen often, but it is annoying when it does.

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