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

136155Re: Loading directory of files, into a single file, in VIM

Expand Messages
  • Tim Chase
    Feb 16, 2013
      On 2013-02-16 13:02, Russell Urquhart wrote:
      > I have a directory of html files, (that are actually xml files,
      > misnamed extension wise.) I would like to have all those files
      > loaded, one after another into a single file, is that possible in
      > Vim?

      There are several ways to go about this. One can create the combined
      file on-disk with something like

      vim *.html
      :argdo w! >> combined.xml

      which will load up each HTML file and then iterate over them,
      appending them to a file on disk.

      Alternatively, you can accumulate them in a register, e.g. "z" with

      vim *.html
      :let @z='' | argdo %y Z

      which will iterate over all your HTML files appending their contents
      to the "z" register (the uppercase version appends, as noted at
      ":help quotea"). It then creates a new buffer, pastes the contents
      of the "z" register, and deletes the blank line under which it was

      Note that in both case, you can modify the range to select a subset
      of the file, so if you just want to write the <body> content, you can
      do something like

      :argdo /<body/+1,/<\/body>/-1w! >> combined.xml

      Hope this gives you some options to work with.


      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Show all 7 messages in this topic