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

padding lines to 80 characters

Expand Messages
  • Denis Perelyubskiy
    hello, is it possible to padd every line, if its length is smaller then 80 characters, to 80 characters with spaces? and if so, how? thanks, denis -- //
    Message 1 of 4 , Aug 31, 2003
    • 0 Attachment
      hello,

      is it possible to padd every line, if its length is
      smaller then 80 characters, to 80 characters with
      spaces? and if so, how?

      thanks,

      denis
      --
      // mailto: Denis Perelyubskiy <lists at overwhelmTAKECAPITALSOUT dot net>
      // icq : 12359698
    • Denis Perelyubskiy
      Hi, Denis. Nice talking to you :) Don t know if there is a better solution, but here ... denis ps. sorry for the spam. it did not occur to me that it was this
      Message 2 of 4 , Sep 1, 2003
      • 0 Attachment
        Hi, Denis. Nice talking to you :)

        Don't know if there is a better solution, but here
        is what works for me:

        :%s/$/<80 or more spaces go here>/g
        :%s/:%s/\%80c *$//g

        denis

        ps. sorry for the spam. it did not occur to me that it was
        this simple before posting :(

        On Sun, 31 Aug 2003 22:39:14 -0800,
        "Denis Perelyubskiy" <lists@...> said:
        > hello,
        >
        > is it possible to padd every line, if its length is
        > smaller then 80 characters, to 80 characters with
        > spaces? and if so, how?
        >
        > thanks,
        >
        > denis
        > --
        > // mailto: Denis Perelyubskiy <lists at overwhelmTAKECAPITALSOUT dot net>
        > // icq : 12359698
        --
        // mailto: Denis Perelyubskiy <lists at overwhelmTAKECAPITALSOUT dot net>
        // icq : 12359698
      • John Aldridge
        ... Actually, the caret (^) shouldn t be necessary, but I think it clarifies the regex. ~ ~ ~ John R. Aldridge, Jr.
        Message 3 of 4 , Sep 1, 2003
        • 0 Attachment
          The old vi way would be:

          >:%s/$/<80 or more spaces go here>/g

          :%s/^.\{80\}/&/

          Actually, the caret (^) shouldn't be necessary,
          but I think it clarifies the regex.

          ~
          ~
          ~
          "John R. Aldridge, Jr."

          At 03:30 09-01-2003, Denis Perelyubskiy wrote:

          >Hi, Denis. Nice talking to you :)
          >
          >Don't know if there is a better solution, but here
          >is what works for me:
          >
          >:%s/$/<80 or more spaces go here>/g
          >:%s/:%s/\%80c *$//g
          >
          >denis
          >
          >ps. sorry for the spam. it did not occur to me that it was
          >this simple before posting :(
          >
          >On Sun, 31 Aug 2003 22:39:14 -0800,
          >"Denis Perelyubskiy" <lists@...> said:
          > > hello,
          > >
          > > is it possible to padd every line, if its length is
          > > smaller then 80 characters, to 80 characters with
          > > spaces? and if so, how?
          > >
          > > thanks,
          > >
          > > denis
          > > --
          > > // mailto: Denis Perelyubskiy <lists at overwhelmTAKECAPITALSOUT dot net>
          > > // icq : 12359698
          >--
          >// mailto: Denis Perelyubskiy <lists at overwhelmTAKECAPITALSOUT dot net>
          >// icq : 12359698
        • Antony Scriven
          ... Interesting quoting style! Anyway, that just replaces 80 chars with itself. ?? Maybe a naughty program somewhere trimmed them. The ^ isn t necessary, but I
          Message 4 of 4 , Sep 1, 2003
          • 0 Attachment
            John Aldridge wrote:

            > The old vi way [for padding a line] would be:
            >
            > >:%s/$/<80 or more spaces go here>/g
            >
            > :%s/^.\{80\}/&/
            >
            > Actually, the caret (^) shouldn't be necessary,
            > but I think it clarifies the regex.

            Interesting quoting style! Anyway, that just replaces 80
            chars with itself. ?? Maybe a naughty program somewhere
            trimmed them. The ^ isn't necessary, but I always throw them
            in too. If you really want a vi-compatible way to pad lines
            to 80 chars, try this.

            :%!expand^Mo^[S^[80a.^[0i:g/^.\{0,80\}$/s/.*/&^[A/|s/^\(.\{80\}\).*/\1^["yyy@y

            You need to replace ^M with a real ctrl-M and all ^[s with
            real <Esc>s. Then suck the line into a register and execute
            it: "xyy@x You may need to :redraw afterwards. The `S' is to
            overcome :se ai if you try it in in Vim.

            expand removes tabs (assuming ts=8) otherwise the padding
            can look like it's wrong, even though it will be to 80 real
            characters, not screen columns. If you have control
            characters in lines it will still look messy however. I've
            used dots not spaces in the example so you can see the
            result. Lines longer than 80 are untouched. I could really
            have done it for lines longer than 79 chars, but never mind.

            There's quite a lot you can do with standard vi. Using vim's
            features, however, makes this sort of thing much more robust.
            That's obvious; I don't know why I said that.

            Anyway the OPs method is a good one.

            Antony (go vi, go!)
          Your message has been successfully submitted and would be delivered to recipients shortly.