I am interested in editing multiple files. Using this answer:

How to edit files non-interactively (e.g. in pipeline)?

I came up with my own test case:

seq 10 14 | tee pa.txt > qu.txt
ex -sc 'argdo %s/1/Z/ge|x' *.txt

However when I run the Ex command, the terminal just hangs, it does not complete the command. If I remove the -s, the command still hangs with this output:

"pa.txt" 5 lines, 15 characters
Entering Ex mode.  Type "visual" to go to Normal mode.
  • It does not on my machine using zsh, can you add your configuration?
    – nobe4
    Apr 15 '16 at 6:05
  • 1
    First remove the -s of your second command, if you are trying to debug something the silent mode isn't helping. Then man ex says that you need to put double quote around your command if it contains spaces so you should also change that. Once it is done you can give us what vim says and it will probably be easier to help you :-)
    – statox
    Apr 15 '16 at 7:46
  • 1
    I second Nobe4. The command works fine, if ex is actually Vim. If it is actually ex (say, from ex-vi), I get an error about argdo and ex waits around for me to enter commands.
    – muru
    Apr 15 '16 at 8:29
  • 1
    Hmm, that looks like Vim. What does ex --version say?
    – muru
    Apr 15 '16 at 18:43

muru’s comment lead me to the answer. According to the docs, argdo requires the listcmds feature at compile time. It appears I do not have it:

$ ex --version | grep -e Features -e listcmds
Small version without GUI.  Features included (+) or not (-):
-cursorshape     -listcmds        -reltime         +windows

Here is a workaround:

for b in *.txt
  ex -sc '%s/1/Z/|x' "$b"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.