Given the following files with two trailing spaces at the end:
$ echo "test1 " > test1.txt; echo "test2 " > test2.txt; echo "test3 " > test3.txt
$ hexdump -C *.txt
00000000 74 65 73 74 31 20 20 0a 74 65 73 74 32 20 20 0a |test1 .test2 .|
00000010 74 65 73 74 33 20 20 0a |test3 .|
00000018
I'm trying to use argdo
to remove trailing spaces, but it seems it applies the changes only to the last file.
So basically I do:
$ vim *.txt
Then in Vim I'm checking:
:args
[test1.txt] test2.txt test3.txt
:argdo! %s/\s\+$//e
"test2.txt" 1 line, 8 characters
"test3.txt" 1 line, 8 characters
:args
test1.txt test2.txt [test3.txt]
:xa " To save all changed buffers and exit.
However only the last file has been modified:
$ hexdump -C *.txt
00000000 74 65 73 74 31 20 20 0a 74 65 73 74 32 20 20 0a |test1 .test2 .|
00000010 74 65 73 74 33 0a |test3.|
As far as I can read in the help (:help :argdo
), it:
Execute {cmd} for each file in the argument list
I believe it works with bufdo
, but why it doesn't work with argdo
?
Any reason why it doesn't work as expected and how to fix it?
vim -N -u NONE
vim -N -u NONE *.txt
), but it seems it's still the same. Tested with Vim v7.3 (Linux) & v7.4 (OS X).