I have a list of files like step-1.py
, step-2.py
etc and if I try to open them with vim files-*.py
then I get a list of buffers like:
:ls
1 %a "step-10.py"
2 "step-11.py"
3 "step-12.py"
4 "step-13.py"
5 "step-14.py"
6 "step-15.py"
7 "step-16.py"
8 "step-17.py"
9 "step-18.py"
10 "step-19.py"
11 "step-1.py"
12 "step-2.py"
13 "step-3.py"
14 "step-4.py"
15 "step-5.py"
16 "step-6.py"
17 "step-7.py"
18 "step-8.py"
19 "step-9.py"
but I want the files to be loaded in order so that the buffer number corresponds to the step number (:b6
should load a buffer with step-6.py
file in it).
So I've been trying to use craft the list in the proper order and supply it to vim... like...
ls step-* | sort -n -t- -k2 | vim -
...but that just loads a single unnamed buffer with the contents step-1.py step-2.py step-3.py step-4.py step-5.py step-6.py step-7.py step-8.py step-9.py step-10.py step-11.py step-12.py step-13.py step-14.py step-15.py step-16.py step-17.py step-18.py step-19.py
.
If I instead try that like files=$(ls step-* | sort -n -t- -k2); vim $files
then that still just gives me an empty buffer like:
:ls
1 %a "step-1.py step-2.py step-3.py step-4.py step-5.py step-6.py step-7.py step-8.py step-9.py step-10.py step-11.py step-12.py step-13.py step-14.py step-15.py step-16.py step-17.py step-18.py step-19.py " line 1
How do I achieve this?
step-01.py
That would solve the problem.