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

Please explain Regex

Expand Messages
  • vicky b
    Hello All, Recently i cam across this command :g /^/m0 which reverses order o line can any body explain how this works Once more doubt i have is CTRL_0 i
    Message 1 of 8 , Jan 9, 2013
    • 0 Attachment
      Hello All,

        Recently i cam across this command :g /^/m0   which   reverses order o line can any body explain how  this works

        Once more doubt i have is CTRL_0 i think this should copy object  what is it really please  explain



      --
      Thanks & Regards
       Vickyb


      --
      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
    • David Fishburn
      ... starting at the top and moving to the bottom. The pattern /^ says match at the start of a line, so it will match every line in the buffer. /m0 says, m ove
      Message 2 of 8 , Jan 9, 2013
      • 0 Attachment



        On Wed, Jan 9, 2013 at 7:25 AM, vicky b <vickyb2084@...> wrote:
        Hello All,

          Recently i cam across this command :g /^/m0   which   reverses order o line can any body explain how  this works

        :g without a range specified will operate on each line in the buffer starting at the top and moving to the bottom.

        The pattern /^ says match at the start of a line, so it will match every line in the buffer.

        /m0 says, "m"ove the line I am on to line 0 (the top of the buffer).

        So, line 1 moves to the top.
        line 2 moves to the top.
        line 3 moves to the top.

        Eventually, the file is reversed.

        HTH,
        David

        --
        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
      • Karthick Gururaj
        ... Google vim reverse lines - the first hit is: http://vim.wikia.com/wiki/Reverse_all_lines ... Don t understand - why do you think CTRL-0 should copy a
        Message 3 of 8 , Jan 9, 2013
        • 0 Attachment

          On Wed, Jan 9, 2013 at 5:55 PM, vicky b <vickyb2084@...> wrote:
          Hello All,

            Recently i cam across this command :g /^/m0   which   reverses order o line can any body explain how  this works
          Google "vim reverse lines" - the first hit is: http://vim.wikia.com/wiki/Reverse_all_lines 

            Once more doubt i have is CTRL_0 i think this should copy object  what is it really please  explain
           Don't understand - why do you think CTRL-0 should copy a text object? 




          --
          Thanks & Regards
           Vickyb


          --
          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 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
        • Tim Chase
          ... The :g command takes a pattern (in this case ^ , or the start-of-line which matches on every line) and performs an Ex command on it (in this case m0
          Message 4 of 8 , Jan 9, 2013
          • 0 Attachment
            On 01/09/13 06:25, vicky b wrote:
            > Recently i cam across this command :g /^/m0 which reverses
            > order o line can any body explain how this works

            The :g command takes a pattern (in this case "^", or the
            start-of-line which matches on every line) and performs an Ex
            command on it (in this case "m0" which means move the line to become
            the first line in the file). So it matches the 1st line, moves it
            to the top (a noop), matches the 2nd line, moves it to the top (now
            above what was the 1st line), matches the 3rd line, moves it to the
            top (now above line 2 which was above line 1), etc, for every line
            in the file.

            You can read more at

            :help :g
            :help :move

            > Once more doubt i have is CTRL_0 i think this should copy object
            > what is it really please explain

            Do you mean control+{capital-oh} or control+zero? You typed
            control+zero which I don't believe that Vim recognizes (let alone
            copies a text object...I'm not sure why you think this should
            happen). However, in Insert mode, you can use control+oh to issue
            one Normal mode command and then return to insert mode. I often do
            this to scroll up or down, using something like

            {control+o}10{control+Y}


            As an aside, I don't know if it's a bug, but i_CTRL-\_CTRL-o is
            supposed to act like i_CTRL-o without moving the cursor, but in at
            least my stock Debian 7.2.445, doing

            {ctrl-\}{ctrl-o}yis

            in the middle of a sentence moves the cursor to the beginning of the
            sentence. Can somebody running a more recent version test this for me?

            -tim




            --
            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
          • Kazuo Teramoto
            ... The same for me, i.e., {ctrl- }{ctrl-o}yis move the cursor to the same place yis moves the cursor. I have vim 7.3.754 from Arch Linux. Regards, Kazuo
            Message 5 of 8 , Jan 9, 2013
            • 0 Attachment
              On 09 Jan 2013 at 10:59:36 -0200, Tim Chase wrote:
              > As an aside, I don't know if it's a bug, but i_CTRL-\_CTRL-o is
              > supposed to act like i_CTRL-o without moving the cursor, but in at
              > least my stock Debian 7.2.445, doing
              >
              > {ctrl-\}{ctrl-o}yis
              >
              > in the middle of a sentence moves the cursor to the beginning of the
              > sentence. Can somebody running a more recent version test this for
              > me?

              The same for me, i.e., {ctrl-\}{ctrl-o}yis move the cursor to the same
              place yis moves the cursor.

              I have vim 7.3.754 from Arch Linux.

              Regards,
              Kazuo Teramoto
            • Tim Chase
              ... Bram, et al., According to :help i_CTRL- _CTRL-O , it should not move the cursor. However, as demonstrated above using ^ ^Oyis the cursor does end up
              Message 6 of 8 , Jan 9, 2013
              • 0 Attachment
                On 01/09/13 07:06, Kazuo Teramoto wrote:
                > On 09 Jan 2013 at 10:59:36 -0200, Tim Chase wrote:
                >> As an aside, I don't know if it's a bug, but i_CTRL-\_CTRL-o is
                >> supposed to act like i_CTRL-o without moving the cursor, but in at
                >> least my stock Debian 7.2.445, doing
                >>
                >> {ctrl-\}{ctrl-o}yis
                >>
                >> in the middle of a sentence moves the cursor to the beginning of the
                >> sentence. Can somebody running a more recent version test this for
                >> me?
                >
                > The same for me, i.e., {ctrl-\}{ctrl-o}yis move the cursor to the same
                > place yis moves the cursor.
                >
                > I have vim 7.3.754 from Arch Linux.

                Bram, et al.,

                According to ":help i_CTRL-\_CTRL-O", it should not move the cursor.
                However, as demonstrated above using

                ^\^Oyis

                the cursor does end up moving, even in fairly recent builds as
                confirmed by Kazuo.

                -tim



                --
                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
              • vicky b
                in insert mode i tried CTRL-o2CTRL-y it should have moved scroll up but it dint i am using vim 7.3 on window ... -- *Thanks & Regards Vickyb * -- You
                Message 7 of 8 , Jan 9, 2013
                • 0 Attachment
                  in insert mode i tried CTRL-o2CTRL-y  it  should have moved scroll up but it  dint i  am using vim 7.3  on window


                  On Wed, Jan 9, 2013 at 6:36 PM, Kazuo Teramoto <kaz.rag@...> wrote:
                  On 09 Jan 2013 at 10:59:36 -0200, Tim Chase wrote:
                  > As an aside, I don't know if it's a bug, but i_CTRL-\_CTRL-o is
                  > supposed to act like i_CTRL-o without moving the cursor, but in at
                  > least my stock Debian 7.2.445, doing
                  >
                  >    {ctrl-\}{ctrl-o}yis
                  >
                  > in the middle of a sentence moves the cursor to the beginning of the
                  > sentence.  Can somebody running a more recent version test this for
                  > me?

                  The same for me, i.e., {ctrl-\}{ctrl-o}yis move the cursor to the same
                  place yis moves the cursor.

                  I have vim 7.3.754 from Arch Linux.

                  Regards,
                  Kazuo Teramoto



                  --
                  Thanks & Regards
                   Vickyb


                  --
                  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
                • Tim Chase
                  ... It should have scrolled *down* (shown text that was previously off the top of the screen), assuming there was any text off the screen. You can try using
                  Message 8 of 8 , Jan 9, 2013
                  • 0 Attachment
                    On 01/09/13 07:37, vicky b wrote:
                    > in insert mode i tried CTRL-o2CTRL-y it should have moved scroll up but
                    > it dint i am using vim 7.3 on window

                    It should have scrolled *down* (shown text that was previously off
                    the top of the screen), assuming there was any text off the screen.
                    You can try using CTRL-e instead of CTRL-y to scroll in the
                    opposite direction (show more text off the bottom of the screen).

                    -tim




                    --
                    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
                  Your message has been successfully submitted and would be delivered to recipients shortly.