Cycle through filenames in vim
Your code can be improved in many aspects, so it is easier to write my own solution rather to rewrite your.

Differences from your:


I suggest to use glob() function to find all files, which are matching to a pattern.
Singular Move(move_direction) function is enough, a duplication is not needed.
Not only new files are opened, but switching between already opened buffers are supported.




function! s:MyCompare(i1, i2)
    let l:f = str2nr(matchstr(a:i1, '[0-9]\+'))
    let l:s = str2nr(matchstr(a:i2, '[0-9]\+'))
    return l:f == l:s ? 0 : l:f &gt; l:s ? 1 : -1
endfunc

function! s:Move(step)
    let l:current_filename = bufname('%')
    let l:common_part = matchstr(l:current_filename, '[^0-9]*')

    "" sort() is needed for numerical order
    let l:matched_file_list = sort(glob(l:common_part . '*', 0, 1), 's:MyCompare') 

    let l:list_size = len(l:matched_file_list)
    let l:cur_idx = index(l:matched_file_list, l:current_filename)

    let l:next_idx = (l:cur_idx + a:step) % l:list_size
    let l:next_buf_name = l:matched_file_list[l:next_idx]

    if !bufloaded(l:next_buf_name)
        execute 'e' l:next_buf_name
    endif

    execute 'buffer' l:next_buf_name
endfunction

command! Fwrd call s:Move(1)
command! Bwrd call s:Move(-1)

noremap &lt;Leader&gt;c :Fwrd&lt;CR&gt;
noremap &lt;Leader&gt;d :Bwrd&lt;CR&gt;


Directory content

ls -1

long_boring_filename_del_101.tex
long_boring_filename_del_1.tex
long_boring_filename_del_202.tex
long_boring_filename_del_2.tex
long_boring_filename_del_3.sty
long_boring_filename_del_4.tex
long_boring_filename_del_5.tex


Demonstration

, is a Leader key.