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

regex or function for deleting spaces in mail quote string

Expand Messages
  • Christian Ebert
    Hello, I am looking for a regex or function to shrink the indenting of higher quote levels in mails. Text should become Text (w/o ) ... which
    Message 1 of 5 , Dec 2, 2004
    • 0 Attachment
      Hello,

      I am looking for a regex or function to shrink the indenting of
      higher quote levels in mails.

      "> > > Text" should become ">>> Text" (w/o ")

      So far I've come up with the following:

      :%g/^>/:s/>\s\+\ze>/>/g

      which (simplified) works but would turn

      "Text > > >"

      into

      "Text >>>"

      too. I could do it in python by parsing each quoted line from the
      beginning and stopping the loop when a "non-quote-char" follows,
      but I wonder how I could do it in vim. Can anyone think of a
      regex solution or must I do it in a function (which would be more
      or less my first in vimspeak)?

      c
      --
      --->> <http://www.blacktrash.org/>
    • Luc Hermitte
      Hello, ... HTH, -- Luc Hermitte http://hermitte.free.fr/vim/
      Message 2 of 5 , Dec 2, 2004
      • 0 Attachment
        Hello,

        * On Thu, Dec 02, 2004 at 10:22:38AM +0100, Christian Ebert <blacktrash@...> wrote:
        > "> > > Text" should become ">>> Text" (w/o ")

        Try this:

        :s/^[> ]\+/\=substitute(submatch(0),' ', '', 'g').' '

        :h :substitute
        :h sub-replace-expression

        HTH,

        --
        Luc Hermitte
        http://hermitte.free.fr/vim/
      • Antony Scriven
        Hello ... Antony
        Message 3 of 5 , Dec 2, 2004
        • 0 Attachment
          Hello

          Christian Ebert wrote:

          > I am looking for a regex or function to shrink the indenting of
          > higher quote levels in mails.
          >
          > "> > > Text" should become ">>> Text" (w/o ")

          Try something like this:

          :s/\(^[> ]*\)\@<= >/>/g

          :help /\@<= (and friends)

          Antony
        • Christian Ebert
          Bonjour Luc, ... Great. Thanks. ... Yup. And with an example I can actually use it s always easier for me to start getting a grip on the matter. ... Sure did.
          Message 4 of 5 , Dec 2, 2004
          • 0 Attachment
            Bonjour Luc,

            * Luc Hermitte on Thu, Dec 02, 2004:
            > * On Thu, Dec 02, 2004 at 10:22:38AM +0100, Christian Ebert <blacktrash@...> wrote:
            >> "> > > Text" should become ">>> Text" (w/o ")
            >
            > Try this:
            >
            > :s/^[> ]\+/\=substitute(submatch(0),' ', '', 'g').' '

            Great. Thanks.

            >:h :substitute
            >:h sub-replace-expression

            Yup. And with an example I can actually use it's always easier
            for me to start getting a grip on the matter.

            > HTH,

            Sure did.

            c
            --
            Try halting your sub-vocal speech. Try to achieve even ten
            seconds of inner silence. You will encounter a resisting
            organism that forces you to talk. That organism is the word.
            ~ W. S. Borroughs, The Ticket That Exploded
          • Alan G Isaac
            ... http://www.american.edu/econ/notes/aimail.vim has this and a few other things. hth, Alan Isaac
            Message 5 of 5 , Dec 2, 2004
            • 0 Attachment
              On Thu, 2 Dec 2004, Christian Ebert apparently wrote:
              > I am looking for a regex or function to shrink the indenting of
              > higher quote levels in mails.

              http://www.american.edu/econ/notes/aimail.vim
              has this and a few other things.

              hth,
              Alan Isaac
            Your message has been successfully submitted and would be delivered to recipients shortly.