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

Re: OT: xargs & vi



On Wed, Jan 09, 2002 at 10:11:56PM +0100, martin f krafft wrote:
| also sprach nori heikkinen <nori@sccs.swarthmore.edu> [2002.01.09.1716 +0100]:
| > hosing up the telnet session, yes.  i would guess.  but using vimm
| > 6.0.93 locally, i get the same results and error messages inputting to
| > vim from stdin.  i can't reproduce your conclusive results on my
| > machine, martin ...
| 
| wow, i can't either anymore. seriously. and i swear it worked yesterday.

You left the 'xargs' out of your conclusion statement.

| but you know what, this is getting tiring... here the summary
| 
| to open a list of files given by a command in vim:
| 
|   vim `command`

This works.  What did "command" output for you?  I do this all the
time, eg

    vim `find src -name \*.java -print`

| if this complains about too long an argument list,

Hmm, yeah, I guess that could happen.

| you either should reconsider (noone wants to edit 500 files), or:
| 
|   for i in `command`; do vi $i; done
| 
| which is exactly why xargs was created in the first place.
| 
| contrary to expectations,
| 
|   command | xargs vim
| 
| works with an error message, but it hoses your terminal.

Not all terminals.  See ":help --"

~~~~~~~~~~~~~~~~
-       This argument can mean two things, depending on whether Ex
        mode is to be used.

        Starting in Normal mode:
    vim -   or  ex -v -
        Start editing a new buffer, which is filled with text
        that is read from stdin.  The commands that would normally be
        read from stdin will now be read from stderr.  Example:
            find . -name "*.c" -print | vim -
        The buffer will be marked modified, because it contains text
        that needs to be saved.  Except when in readonly mode, then
        the buffer is not marked modified.  Example:
            ls | view -
~~~~~~~~~~~~~~~~

I guess some terms don't like sending keystrokes on stderr.

| any form of 'vim -' will read the data to be edited from stdin, not the
| filenames, so it's not appropriate.
| 
| and even though i swear it worked,
| 
|   command | vim
| 
| just dies with
| 
| Vim: Warning: Input is not from a terminal
| Vim: Error reading input, exiting...
| Vim: Finished.

Yeah, again :


    command | xargs vim -

works, in gnome-terminal at least.  I expect that

    command | xargs gvim

will work regardless since gvim has no ties to the console.

-D

-- 

If your life is a hard drive,
Christ can be your backup.



Reply to: