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

Re: delete Numbera of lines every Numberb of lines

Expand Messages
  • Antony Scriven
    ... Antony
    Message 1 of 7 , Dec 1, 2005
    • 0 Attachment
      On Dec 01, Tim Chase wrote:

      > [...]
      >
      > let delcount=0 | g/^/if ((delcount+line("."))%10!=0) | d | let
      > delcount=delcount + 1| endif

      You could shorten that somewhat, if you wanted:

      :let i=0 | g/^/ let i=i+1 | if i%10 | d

      Antony
    • Preben 'Peppe' Guldberg
      ... Assuming you want to keep the first and every tenth line in the buffer, you could use eg. ... Here nine lines are deleted and the tenth is moved after
      Message 2 of 7 , Dec 1, 2005
      • 0 Attachment
        Vim Visual wrote:

        > do you know how to delete, say, nine lines every ten lines in a data file?

        Assuming you want to keep the first and every tenth line in the buffer,
        you could use eg.

        :g/^/+d9

        If you want to keep every tenth line, you need a little magic:

        :g/^/d9|m.

        Here nine lines are deleted and the tenth is moved after itself.
        This little trick removes the tenth line from the list of lines that
        :global processes (as does the deletion of line 2 to 9).

        Peppe
        --
        se nocp cpo=BceFsx!$ hid bs=2 ls=2 hls ic " P. Guldberg /bin/vi@...
        se scs ai isf-== fdo-=block cino=t0,:0 hi=100 ru so=4 noea lz|if has('unix')
        se sh=/bin/sh|en|syn on|filetype plugin indent on|ono S V/\n^-- $\\|\%$/<CR>
        cno <C-A> <C-B>|au FileType vim,mail se sw=4 sts=4 et|let&tw=72+6*(&ft=~'v')
      Your message has been successfully submitted and would be delivered to recipients shortly.