Welcome to Vifm Q&A, where you can ask questions about using Vifm. Registration is optional, anonymous posts are moderated. E-mail and GitHub logins are enabled.
0 votes
in vifm by

Is there a way to accept [count] in custom maps like [N]gt? In vim v:count and v:count1 can be used to achieve this. However in vifm I get No Range Allowed error.

I am trying to create bindings that jumps to the Nth last/first modified file in the directory.

nnoremap <silent> gn :exe 'goto' fnameescape(system('ls -Atp ' . expand('%d') . ' | grep -vm' . v:count1 . ' / | tail -n 1'))<CR>
nnoremap <silent> gN :exe 'goto' fnameescape(system('ls -Artp ' . expand('%d') . ' | grep -vm' . v:count1 . ' / | tail -n 1'))<CR>

An example of this used in vim is given below:

def JumpToBuffer(bufnr: number, rev: bool = v:false)
  if rev
    if bufnr == 0
      bprevious!
    else
      exec $":{bufnr}bprevious!"
    endif
  else
    if bufnr == 0
      bnext!
    else
      if !bufnr->bufexists()
        return
      else
        exec $'buffer! {bufnr}'
      endif
    endif
  endif
enddef
nnoremap <silent> gb :<C-U>call <SID>JumpToBuffer(v:count)<CR>
nnoremap <silent> gB :<C-U>call <SID>JumpToBuffer(v:count, v:true)<CR>

1 Answer

+1 vote
by
selected by
 
Best answer

Your Vifm mappings lack <C-U> that you have in Vim commands. You need them for the same reason: count before : starts command-line mode with a range.

by

count before : starts command-line mode with a range

Silly me. Thanks for pointing it out.

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