2

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.
:
Zombo
  • 1
  • 5
  • 18
  • It does not on my machine using zsh, can you add your configuration? – nobe4 Apr 15 '16 at 06: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 07: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 08:29
  • 1
    Hmm, that looks like Vim. What does ex --version say? – muru Apr 15 '16 at 18:43

1 Answers1

2

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
do
  ex -sc '%s/1/Z/|x' "$b"
done
Zombo
  • 1
  • 5
  • 18
  • That explains your recent post on [ubuntu.se]. I wondered why it didn't use bufdo or argdo. – muru Apr 16 '16 at 16:03
  • 1
    @muru also because argdo is not POSIX http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html, nor is {1..4} – Zombo Apr 16 '16 at 16:42