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

137705Re: vim: format each long lines and insert just one break afterward

Expand Messages
  • Gary Johnson
    May 18 2:33 PM
    • 0 Attachment
      On 2013-05-18, ping wrote:
      > tested long time no good results...
      >
      > so the goal here sounds simple: say I have
      >
      > * a long text file (over 50K lines), and
      > * each line by itself is a nature paragraph, so sometime is very long
      > (over 1000 charactors).
      > * there are sometimes one of more empty line in between, sometimes not
      >
      > I wanted to format it into:
      >
      > 1. if 2 lines are adjoining, add an empty line to as a break
      > 2. if 2 lines already have more than 1 empty lines in between, remove
      > the extra and make sure only one empty line left.

      This is equivalent to replacing a sequence of one or more newlines
      with two newlines.

      :%s/\n\+/\r\r/

      > 3. trunk the long lines to multiple lines with each of 80 charactors

      :set tw=80
      gggqG

      Regards,
      Gary

      --
      --
      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 9 messages in this topic