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

stripping lines

Expand Messages
  • Nikolai 'pcp' Weibull
    is there any way from vim (except from using shell commands) to strip ... but can t find any functions that will help...anyone have any suggestions? -- /*
    Message 1 of 9 , Jul 31, 2001
    • 0 Attachment
      is there any way from vim (except from using shell commands) to strip
      certain lines (i.e. blank lines) with a :s? i'm thinking something like:
      :%s/^\s*$/\= ... /
      but can't find any functions that will help...anyone have any suggestions?

      --
      /* Name: Nikolai 'pcp' Weibull, Age: 21, Place of Birth: Chicago, IL USA *
      * Current Location: Gothenburg, Sweden, Homepage: http://www.pcppopper.org/ *
      * System: Midi ATX, ASUS CUV4X, Celeron 667@950, Fujitsu 20.49gb UDMA-66, *
      * Geforce2 MX 32, 256mb PC133 E-Mail: da.box@..., pcp@... */
    • Mark Zealey
      ... maybe? note the _, this isn t perl ;( -- Mark Zealey (aka JALH on irc.openprojects.net: #zealos and many more) mark@itsolve.co.uk UL++++ $
      Message 2 of 9 , Jul 31, 2001
      • 0 Attachment
        On Tue, Jul 31, 2001 at 03:16:10PM +0200, Nikolai 'pcp' Weibull wrote:

        > is there any way from vim (except from using shell commands) to strip
        > certain lines (i.e. blank lines) with a :s? i'm thinking something like:
        > :%s/^\s*$/\= ... /
        > but can't find any functions that will help...anyone have any suggestions?

        :%s/^\_s*$\n//

        maybe? note the _, this isn't perl ;(

        --

        Mark Zealey (aka JALH on irc.openprojects.net: #zealos and many more)
        mark@...

        UL++++>$ G!>(GCM/GCS/GS/GM) dpu? s:-@ a16! C++++>$ P++++>+++++$ L+++>+++++$
        !E---? W+++>$ N- !o? !w--- O? !M? !V? !PS !PE--@ PGP+? r++ !t---?@ !X---?
        !R- b+ !tv b+ DI+ D+? G+++ e>+++++ !h++* r!-- y--

        (www.geekcode.com)
      • Mark Zealey
        ... oops, the _ only means that it can match a linebreak too, no need for it -- Mark Zealey (aka JALH on irc.openprojects.net: #zealos and many more)
        Message 3 of 9 , Jul 31, 2001
        • 0 Attachment
          On Tue, Jul 31, 2001 at 02:21:55PM +0100, I wrote:

          > :%s/^\_s*$\n//
          >
          > maybe? note the _, this isn't perl ;(

          oops, the _ only means that it can match a linebreak too, no need for it

          --

          Mark Zealey (aka JALH on irc.openprojects.net: #zealos and many more)
          mark@...

          UL++++>$ G!>(GCM/GCS/GS/GM) dpu? s:-@ a16! C++++>$ P++++>+++++$ L+++>+++++$
          !E---? W+++>$ N- !o? !w--- O? !M? !V? !PS !PE--@ PGP+? r++ !t---?@ !X---?
          !R- b+ !tv b+ DI+ D+? G+++ e>+++++ !h++* r!-- y--

          (www.geekcode.com)
        • Benji Fisher
          ... After :g/pat/ you can put any Command-mode command (:d here). The most common is g/pat/s//text/ . ... HTH --Benji Fisher
          Message 4 of 9 , Jul 31, 2001
          • 0 Attachment
            Nikolai 'pcp' Weibull wrote:
            >
            > is there any way from vim (except from using shell commands) to strip
            > certain lines (i.e. blank lines) with a :s? i'm thinking something like:
            > :%s/^\s*$/\= ... /
            > but can't find any functions that will help...anyone have any suggestions?

            Use :g instead of :%s , like this:

            :g/^\s*$/d

            After :g/pat/ you can put any Command-mode command (:d here). The most common
            is g/pat/s//text/ .

            :help :global

            HTH --Benji Fisher
          • Denis Perelyubskiy
            ... so, does this mean that anything you can do with %s you can do with g ? denis -- /* * Denis Perelyubskiy * icq : 12359698 * mailto: denisp@CS.UCLA.EDU
            Message 5 of 9 , Jul 31, 2001
            • 0 Attachment
              On Tue, 31 Jul 2001, Benji Fisher wrote:

              >Nikolai 'pcp' Weibull wrote:
              >>
              >> is there any way from vim (except from using shell commands) to strip
              >> certain lines (i.e. blank lines) with a :s? i'm thinking something like:
              >> :%s/^\s*$/\= ... /
              >> but can't find any functions that will help...anyone have any suggestions?
              >
              > Use :g instead of :%s , like this:
              >
              >:g/^\s*$/d
              >
              >After :g/pat/ you can put any Command-mode command (:d here). The most common
              >is g/pat/s//text/ .

              so, does this mean that anything you can do with %s you can
              do with 'g' ?

              denis

              --

              /*
              * Denis Perelyubskiy
              * icq : 12359698
              * mailto: denisp@...
              * PGP : http://www.cs.ucla.edu/~denisp/files/pgp.asc
              */
            • Benji Fisher
              ... [snip] ... Sure. The docs (a couple of lines above :help complex-repeat) point out that ... is two characters shorter than ... There are many things you
              Message 6 of 9 , Jul 31, 2001
              • 0 Attachment
                Denis Perelyubskiy wrote:
                >
                [snip]
                > >After :g/pat/ you can put any Command-mode command (:d here). The most common
                > >is g/pat/s//text/ .
                >
                > so, does this mean that anything you can do with %s you can
                > do with 'g' ?
                >
                > denis

                Sure. The docs (a couple of lines above :help complex-repeat) point out
                that

                :%s/pat/PAT/g

                is two characters shorter than

                :g/pat/s//PAT/g

                There are many things you can do with :g that cannot be done with :s . Here
                is an example that you might be able to do with :s if you really wanted to:

                :g/foo/s/bar/bar (near foo)/g

                --Benji Fisher
              • Vonlia
                ... You don t need global for this example. Try this: /foo/s/bar/bar (near foo)/g ... -- Oops, I bumped the table. What a wretched, wretched table. -- Robert
                Message 7 of 9 , Aug 1, 2001
                • 0 Attachment
                  On Tue, 31 Jul 2001, Benji Fisher wrote:

                  > > so, does this mean that anything you can do with %s you can
                  > > do with 'g' ?
                  > >
                  > > denis
                  >
                  > Sure. The docs (a couple of lines above :help complex-repeat) point out
                  > that
                  >
                  > :%s/pat/PAT/g
                  >
                  > is two characters shorter than
                  >
                  > :g/pat/s//PAT/g
                  >
                  > There are many things you can do with :g that cannot be done with :s . Here
                  > is an example that you might be able to do with :s if you really wanted to:
                  >
                  > :g/foo/s/bar/bar (near foo)/g

                  You don't need global for this example. Try this:

                  /foo/s/bar/bar (near foo)/g

                  ---this is just 1 char shorter, but it is shorter :-) :help :s [range]


                  --
                  Oops, I bumped the table. What a wretched, wretched table.
                  -- Robert Bateman

                  /|| Vonlia <http://members.home.net/adam.seyfarth/> ||\
                  /«|| <mailto:cloud@...> <http://www.majik3d.org> ||»\
                  \«|| <http://tuxaqfh.sf.net> <http://tuxkart.sf.net> ||»/
                  \|| <http://vim.sf.net> <http://www.majik3d.org> ||/
                • Preben Guldberg
                  ... Eh? How many lines matched /foo/ in that buffer :-) :help :g My vote: g/foo/s/bar/& (near foo)/g Peppe -- Before you criticize someone, walk
                  Message 8 of 9 , Aug 1, 2001
                  • 0 Attachment
                    Thus wrote Vonlia (adam.seyfarth@...) on [010801]:
                    > On Tue, 31 Jul 2001, Benji Fisher wrote:

                    > > :g/foo/s/bar/bar (near foo)/g

                    > You don't need global for this example. Try this:

                    > /foo/s/bar/bar (near foo)/g

                    > ---this is just 1 char shorter, but it is shorter :-) :help :s [range]

                    Eh?

                    How many lines matched /foo/ in that buffer :-) :help :g

                    My vote:

                    g/foo/s/bar/& (near foo)/g

                    Peppe
                    --
                    "Before you criticize someone, walk
                    Preben "Peppe" Guldberg __/-\__ a mile in his shoes. That way, if
                    c928400@... (o o) he gets angry, he'll be a mile away
                    ----------------------oOOo (_) oOOo-- - and barefoot." --Sarah Jackson
                  • Jean Jordaan
                    ... This is with a :g .. from Sven s .vimrc .. ,Sl = squeeze lines Turn all blocks of empty lines (within current visual) into *one* empty
                    Message 9 of 9 , Aug 1, 2001
                    • 0 Attachment
                      > is there any way from vim (except from using shell commands) to
                      > strip certain lines (i.e. blank lines) with a :s?

                      This is with a :g .. from Sven's .vimrc ..

                      " ,Sl = "squeeze lines"
                      " Turn all blocks of empty lines (within current visual)
                      " into *one* empty line:
                      map ;Sl :g/^$/,/./-j

                      --
                      Jean
                    Your message has been successfully submitted and would be delivered to recipients shortly.