Loading ...
Sorry, an error occurred while loading the content.

Sorting using a utility that does not support stdin

Expand Messages
  • David Fishburn
    Vim 6.2.14 WinXP I am using the xmllint utility: xmllint [options] XMLfiles It has a feature --format that will reformat your document. ... Except it doesn t
    Message 1 of 4 , Jun 25, 2003
    • 0 Attachment
      Vim 6.2.14 WinXP

      I am using the xmllint utility:

      xmllint [options] XMLfiles

      It has a feature --format that will reformat your document.
      What I would like to do is:
      :'<,'>!xmllint --format

      Except it doesn't accept stdin.
      This does work:
      :'<,'>!xmllint --format %:p

      But I would like to be able to reformat only a section of the file.
      I was going to create a mapping to do this, but now I think I will need
      a function.

      I am looking for confirmation, or ideas, or if anyone has already done
      this.

      The function will have to redirect the selected text to a new temporary
      file.
      Call xmllint on the temp file.
      Then delete the temp file.

      Thanks,
      Dave

      PS. Here is the usage from xmllint.


      xmllint [options] XMLfiles
      Parse the XML files and output the result of the parsing
      --version : display the version of the XML library used
      --debug : dump a debug tree of the in-memory document
      --shell : run a navigating shell
      --debugent : debug the entities defined in the document
      --copy : used to test the internal copy implementation
      --recover : output what was parsable on broken XML documents
      --noent : substitute entity references by their value
      --noout : don't output the result tree
      --htmlout : output results as HTML
      --nowrap : do not put HTML doc wrapper
      --valid : validate the document in addition to std well-formed check
      --postvalid : do a posteriori validation, i.e after parsing
      --dtdvalid URL : do a posteriori validation against a given DTD
      --timing : print some timings
      --output file or -o file: save to a given file
      --repeat : repeat 100 times, for timing or profiling
      --insert : ad-hoc test for valid insertions
      --sgml : use the DocBook SGML parser
      --html : use the HTML parser
      --push : use the push mode of the parser
      --nowarning : do not emit warnings from parser/validator
      --noblanks : drop (ignorable?) blanks spaces
      --format : reformat/reindent the input
      --testIO : test user I/O support
      --encode encoding : output in the given encoding
      --catalogs : use SGML catalogs from $SGML_CATALOG_FILES
      otherwise XML Catalogs starting from
      file:///etc/xml/catalog are activated by default
      --nocatalogs: deactivate all catalogs
      --auto : generate a small doc on the fly
      --xinclude : do XInclude processing
      --loaddtd : fetch external DTD
      --dtdattr : loaddtd + populate the tree with inherited attributes
      --dropdtd : remove the DOCTYPE of the input docs
      --stream : use the streaming interface to process very large files
      --chkregister : verify the node registration code
      --relaxng schema : do RelaxNG validation against the schema
    • Michael Naumann
      ... David, not sure if it works on XP, but under unix, the following would work ... Note the - for stdin. HTH, Michael
      Message 2 of 4 , Jun 25, 2003
      • 0 Attachment
        On Wednesday 25 June 2003 20:41, David Fishburn wrote:
        > Vim 6.2.14 WinXP
        >
        > I am using the xmllint utility:
        >
        > xmllint [options] XMLfiles
        >
        > It has a feature --format that will reformat your document.
        >
        > What I would like to do is:
        > :'<,'>!xmllint --format

        David, not sure if it works on XP, but under unix, the following would work
        :'<,'>!xmllint --format -

        Note the - for stdin.

        HTH, Michael
      • David Fishburn
        Yes that does work under WinXP. Thanks that makes things much easier. Dave ... From: Michael Naumann [mailto:michael@strux.net] Sent: Wednesday, June 25, 2003
        Message 3 of 4 , Jun 25, 2003
        • 0 Attachment
          Yes that does work under WinXP.

          Thanks that makes things much easier.

          Dave

          -----Original Message-----
          From: Michael Naumann [mailto:michael@...]
          Sent: Wednesday, June 25, 2003 4:11 PM
          To: vim@...
          Subject: Re: Sorting using a utility that does not support stdin


          On Wednesday 25 June 2003 20:41, David Fishburn wrote:
          > Vim 6.2.14 WinXP
          >
          > I am using the xmllint utility:
          >
          > xmllint [options] XMLfiles
          >
          > It has a feature --format that will reformat your document.
          >
          > What I would like to do is:
          > :'<,'>!xmllint --format

          David, not sure if it works on XP, but under unix, the following would
          work :'<,'>!xmllint --format -

          Note the - for stdin.

          HTH, Michael
        • Charles E. Campbell
          ... Unless you re sorting multi-megabyte files, Piet Delport s Bisort() ought to work without going out to the shell. You may get a copy (plus Vissort) under
          Message 4 of 4 , Jun 25, 2003
          • 0 Attachment
            On Wed, Jun 25, 2003 at 04:18:31PM -0400, David Fishburn wrote:
            > Yes that does work under WinXP.
            ---------------------------------------------------------------------

            Unless you're sorting multi-megabyte files, Piet Delport's Bisort()
            ought to work without going out to the shell. You may get a copy
            (plus Vissort) under

            http://www.erols.com/astronaut/vim/index.html#VimFuncs
            as "Visual Block Sorting"

            Actually visual-blocks don't have to be used to invoke
            Vissort; for example,

            :1,5Vissort

            will work, too.

            Regards,
            Chip Campbell

            --
            Charles E Campbell, Jr, PhD _ __ __
            Goddard Space Flight Center / /_/\_\_/ /
            cec@... /_/ \/_//_/
            PGP public key: http://www.erols.com/astronaut/pgp.html
          Your message has been successfully submitted and would be delivered to recipients shortly.