Following up on my comment…
I've created 1000 files named 1.txt
to 1000.txt
with the following command:
$ touch {1..1000}.txt
In Vim, I could use :args *.txt
to load each of them in the argument list but the order will be less than optimal:
1.txt
10.txt
100.txt
1000.txt
101.txt
102.txt
103.txt
104.txt
105.txt
106.txt
107.txt
...
Instead, we could use :help backtick-expansion
:
:args `ls\|sort -g`
Which gives us a more usable order:
1.txt
2.txt
3.txt
4.txt
5.txt
6.txt
7.txt
8.txt
9.txt
10.txt
11.txt
...
From there, you can use argument-related commands to move around:
:n " next argument
:N " previous argument
And map them if that's still too much typing:
nnoremap <Right> :n<CR>
nnoremap <Left> :N<CR>
Since we are at it, why not map our custom :args
command, too?
nnoremap <key> :args `ls\|sort -g`<CR>
NOTE: Feeding the argument list with hundreds of files (from plain *.txt
to structured *.rb
or whatever) is nearly instantaneous and Vim can perfectly handle thousands of buffers so you don't have to fear performance issues.
--- edit ---
Unlike the buffer list, argument lists can be local. This allows you to have different argument lists in different tab pages (or windows, but I find tab pages to be easier to reason about in such a scenario and… that's pretty much their intended use):
$ vim
:arglocal `ls /tmp/a\|sort -g`
:tabnew
:arglocal `ls /tmp/b\|sort -g`
With such a setup, :n
and :N
will cycle through the first argument list in the first tab page and the second argument list in the second tab page.
unimpaired
plugin, with a few tweaks. You can move forward or backward in the filesystem with[f
and]f
, and then repeat your last motion with;
or,
(depending on the direction you want).$ vim *.txt
. Jumping to3.txt
from2.txt
is thus only a matter of:n<CR>
, which you could map to anything if that's still too much typing. The problem is the order in which those files are opened:1.txt, 10.txt, 100.txt, 1000.txt, 101.txt, 102.txt, etc.
but this may or may not affect you depending on your naming scheme.