Re: Feed a list of filenames to vim

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



In article <4DD2A021.4080303@xxxxxxxxxxxx>,
Jussi Hirvi <listmember@xxxxxxxxxxxx> wrote:
> There are some googlable ways to feed a list of filenames to vim, but I 
> stumble on weird results.
> 
> With my filelist, I try to do
> 
> 	cat list | xargs vim
> 
> ...to edit the files listed in the file "list". Here's what happens:
> 
> [root@lasso2 tempdir]# ls -l
> total 8
> -rw-r--r--  1 root root  0 May 17 18:28 a
> -rw-r--r--  1 root root  0 May 17 18:28 b
> -rw-r--r--  1 root root  3 May 17 18:31 c
> -rw-r--r--  1 root root 12 May 17 18:43 list
> [root@lasso2 tempdir]# cat list
> ./a
> ./b
> ./c
> [root@lasso2 tempdir]# cat list | xargs vim
> 3 files to edit
> Vim: Warning: Input is not from a terminal
> 
> Ok, so far, so good. And after this, the file a opens, as expected. 
> However, the contents show as all uppercase. And everything I write is 
> uppercase too. I can move to the next file (:n) even though the command 
> shows as uppercase (:N). I cannot quit vim, however. When I do ":q", I 
> get blank screen, and I have to close the terminal window.
> 
> If I do instead
> 	cat list | xargs less
> ...it works as expected.
> 
> And with
> 	cat list | xargs vi
> ...(in a fresh terminal window), the editing goes just perfect, but when 
> I quit vi, the terminal will not show the commands I write, and the 
> display gets garbled (no newlines etc.).
> 
> What is happening?

The problem is that standard input is being used to send the list of
files to xargs, and vi inherits this standard input. That's why it warns
that input is not from a terminal - it normally expects the user input
to be on standard input.

Try this instead:

vim `cat list`

This will work provided none of the files has a space in its name or
directory path.

Cheers
Tony
-- 
Tony Mountifield
Work: tony@xxxxxxxxxxxxx - http://www.softins.co.uk
Play: tony@xxxxxxxxxxxxxxx - http://tony.mountifield.org
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux