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

Re: replacing

Expand Messages
  • antalsia@free.fr
    Thanks a lot William, it works perfectly !
    Message 1 of 4 , Nov 25, 2004
    • 0 Attachment
      Thanks a lot William, it works perfectly !

      Quoting William Natter <wnatter@...>:

      > antalsia@... wrote:
      >
      > >Hi !
      > >
      > >Sorry if the question is trivial, but I wonder how to replace the EOL by the
      > >NULL caracter...I want to print the content off a file on a single line then
      > >format the text with x caracters per line. Does anyone has a solution ?
      > >
      > >thanks in advanced,
      > >Yoan.
      > >
      > >
      > >
      > >
      > Bonjour Yoan,
      >
      > Assuming x is 10 and that you know how to use some "e" commands (using
      > ":"), my solution would be:
      >
      > :%j
      > :set tw=10
      > gqG
      >
      > Explanations:
      >
      > :%j means for every line in the buffer, join the lines
      > :set tw=10 means set the "textwidth" parameter, also called "tw", to
      > 10. This controls the behaviour of the next command.
      > gqG means format from this line to the last one in the file into the
      > given textwidth.
      > Someone pointed to ggVGJ as a nice alternative to the first command.
      >
      > There are some assumptions made by the above commands with spaces, so if
      > you absolutely require to cut at every single set of x characters, here
      > is something a little better:
      >
      > :%s/\n//
      > :s/.\{10}/&\r/g
      >
      > The first line means: on every line, replace every newline character
      > (\n) with nothing. The second line means: match ten characters, replace
      > them with themselves (&) and a newline (\r).
      >
      > William
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.