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

Re: Deleting a repetative pattern

Expand Messages
  • Jürgen Krämer
    Hi, ... Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact
    Message 1 of 27 , Aug 2, 2006
    • 0 Attachment
      Hi,

      Eric Leenman wrote:
      >
      > I have a file which contains lines like below
      >
      > Line 18 | 200 040 200
      > 200 200 051 200 1C2 200 2E2 Line 18 |
      > 200 040 200 040 200 052 200 1B9 200 2F4
      > Line 18 | 200 040 200
      > 040 200 200 200 1C2 200 2DC
      > Line 18 | 200 040 200
      > 040 200 063 200 1D6 200 2D4
      >
      > How do I deleted per line all the 'odd' 200?
      > So that it becomes like:
      >
      > Line 18 | 040
      > 200 051 1C2 2E2 Line 18 |
      > 040 040 052
      > 1B9 2F4 Line 18 |
      > 040 040 200 1C2 2DC
      > Line 18 | 040
      > 040 063 1D6 2D4

      use the 'g' flag of the substitute command:

      :%s/\<200\>/ /g

      Regards,
      Jürgen

      --
      Sometimes I think the surest sign that intelligent life exists elsewhere
      in the universe is that none of it has tried to contact us. (Calvin)
    • Tim Chase
      ... Notice that his output does have *some* 200s in it. I m not sure what the input/output looks like exactly, as it s possible that MTA/MUAs between Eric and
      Message 2 of 27 , Aug 2, 2006
      • 0 Attachment
        >> Line 18 | 200 040 200
        >> 200 200 051 200 1C2 200 2E2 Line 18 |
        >> 200 040 200 040 200 052 200 1B9 200 2F4
        >> Line 18 | 200 040 200
        >> 040 200 200 200 1C2 200 2DC
        >> Line 18 | 200 040 200
        >> 040 200 063 200 1D6 200 2D4
        >>
        >> How do I deleted per line all the 'odd' 200?
        >> So that it becomes like:
        >>
        >> Line 18 | 040
        >> 200 051 1C2 2E2 Line 18 |
        >> 040 040 052
        >> 1B9 2F4 Line 18 |
        >> 040 040 200 1C2 2DC
        >> Line 18 | 040
        >> 040 063 1D6 2D4
        >
        > use the 'g' flag of the substitute command:
        >
        > :%s/\<200\>/ /g


        Notice that his output does have *some* 200s in it. I'm not sure
        what the input/output looks like exactly, as it's possible that
        MTA/MUAs between Eric and the VimML and my machine have bunged
        with matters. Getting the original text might help:

        bash> head -3 file.txt | xxd | vi -

        should give you a binary dump of the first 3 lines of file.txt
        allowing us to better see where linebreaks and spaces/tabs fall.

        It *sounds* like Eric is looking for something like this
        monsterous one-liner:

        %s/\<\(\x\x\x\)\(\_s\+\x\x\x\)\>/\=((submatch(1)==200)?'
        ':submatch(1)).submatch(2)

        (that's 3 spaces in those quotes, in case of further mailer
        problems, one for each character of "200")

        which finds all the "odd" 200's in the block (as a ":hls" with
        searching on that initial pattern will show it finds)

        However, it doesn't come out with the same results as Eric's
        expected results. Thus, we either have a problem of conveying
        the problem, or there's an error in the expected output.

        -tim
      • Ben K.
        Apologies, this email should have been a reply to the original post rather than to yours. ... Hi, an alternative FWIW ... Ben K. Developer
        Message 3 of 27 , Aug 2, 2006
        • 0 Attachment
          Apologies, this email should have been a reply to the original post rather
          than to yours.

          ==================================
          >Line 18 | 123
          >Line 18 | 641
          >Line 19 | abc
          >Line 19 | GHI
          >Line 332 | xyz
          >Line 332 | vcx

          Hi, an alternative FWIW

          :sort
          :g!/^Line/d

          Ben K.
          Developer
          http://benix.tamu.edu
        • Jürgen Krämer
          Hi, ... %s/ ( %(. {- } ) ? )/ 1/g this again replaces 200 with three spaces; if there is another 200 following with some text between them
          Message 4 of 27 , Aug 2, 2006
          • 0 Attachment
            Hi,

            Eric Leenman wrote:
            >
            > I see that my the 'ASCII-layout' is not what it should be.
            > The command deletes all 200.
            >
            > How can I give the command to deleted only the 1st, 3rd, 5th, 7th, ect..
            > 200?
            > And leaving (if any) the 2nd, 4th, 6th, ect.

            %s/\<200\>\(\%(.\{-\}\<200\>\)\?\)/ \1/g

            this again replaces 200 with three spaces; if there is another 200
            following with some text between them (this text can not contain a third
            200, because of the non-greedy match forced by "\{-\}") we keep this
            200 together with the interspersed text.

            > [snip]
            >
            >>> How do I deleted per line all the 'odd' 200?

            Now I understand. When I read this for the first time, I wondered what's
            so 'strange' about 200 -- I didn't think of 'odd' as the opposite of
            'even'.

            > [snip]
            >
            >> use the 'g' flag of the substitute command:
            >> :%s/\<200\>/ /g
            >
            > [snip]

            Regards,
            Jürgen

            --
            Sometimes I think the surest sign that intelligent life exists elsewhere
            in the universe is that none of it has tried to contact us. (Calvin)
          • Jürgen Krämer
            Hi, ... %s/ ( %(. {- } ) ? )/ 1/g this again replaces 200 with three spaces; if there is another 200 following with some text between them
            Message 5 of 27 , Aug 2, 2006
            • 0 Attachment
              Hi,

              Eric Leenman wrote:
              >
              > I see that my the 'ASCII-layout' is not what it should be.
              > The command deletes all 200.
              >
              > How can I give the command to deleted only the 1st, 3rd, 5th, 7th, ect..
              > 200?
              > And leaving (if any) the 2nd, 4th, 6th, ect.

              %s/\<200\>\(\%(.\{-\}\<200\>\)\?\)/ \1/g

              this again replaces 200 with three spaces; if there is another 200
              following with some text between them (this text can not contain a third
              200, because of the non-greedy match forced by "\{-\}") we keep this
              200 together with the interspersed text.

              > [snip]
              >
              >>> How do I deleted per line all the 'odd' 200?

              Now I understand. When I read this for the first time, I wondered what's
              so 'strange' about 200 -- I didn't think of 'odd' as the opposite of
              'even'.

              > [snip]
              >
              >> use the 'g' flag of the substitute command:
              >> :%s/\<200\>/ /g
              >
              > [snip]

              Regards,
              Jürgen

              --
              Sometimes I think the surest sign that intelligent life exists elsewhere
              in the universe is that none of it has tried to contact us. (Calvin)
            • Ben K.
              ... Just an idea... Regards, Ben K. Developer http://benix.tamu.edu
              Message 6 of 27 , Aug 2, 2006
              • 0 Attachment
                > How do I deleted per line all the 'odd' 200?

                :%s/ 200 200 200 / 200 zzz 200 /g
                :%s/ 200 / /g
                :%s/zzz/200/g

                Just an idea...

                Regards,

                Ben K.
                Developer
                http://benix.tamu.edu
              • Eric Leenman
                Tim, Jurgen, Ben, Thanks, It works. Rgds, Eric _________________________________________________________________ FREE pop-up blocking with the new MSN Toolbar
                Message 7 of 27 , Aug 2, 2006
                • 0 Attachment
                  Tim, Jurgen, Ben,

                  Thanks,
                  It works.

                  Rgds,
                  Eric

                  _________________________________________________________________
                  FREE pop-up blocking with the new MSN Toolbar � get it now!
                  http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
                • Ben K.
                  ... If there are repeated 200 200 200 200 ... ... Regards, Ben K. Developer http://benix.tamu.edu
                  Message 8 of 27 , Aug 2, 2006
                  • 0 Attachment
                    >> How do I deleted per line all the 'odd' 200?
                    If there are repeated 200 200 200 200 ...

                    :%s/200\s\+200\s\+/200 zzz /g


                    Regards,

                    Ben K.
                    Developer
                    http://benix.tamu.edu
                  • Eric Leenman
                    Hi, I have file which contains hexadecimal numbers like below: 04F --- 05F --- 052 --- 188 --- 2D4 --- 173 --- 040 --- 18D 051 --- 040 ---
                    Message 9 of 27 , Aug 2, 2006
                    • 0 Attachment
                      Hi,

                      I have file which contains hexadecimal numbers like below:

                      04F --- 05F --- 052 --- 188 --- 2D4 --- 173 --- 040 --- 18D
                      051 --- 040 --- 05F --- 1CA --- 2E8 --- 14F --- 040 --- 1E2
                      051 --- 040 --- 069 --- 1B9 --- 2D7 --- 15E --- 040 --- 1A6
                      051 --- 040 --- 06F --- 1ED --- 2EB --- 12E --- 040 --- 209
                      051 --- 040 --- 078 --- 1F9 --- 2E3 --- 122 --- 040 --- 220
                      051 --- 045 --- 063 --- 1C8 --- 2D1 --- 146 --- 040 --- 1F4
                      051 --- 046 --- 05A --- 1BB --- 2D7 --- 158 --- 040 --- 1D3
                      051 --- 052 --- 04F --- 1B6 --- 2E3 --- 154 --- 040 --- 1BB
                      052 --- 040 --- 045 --- 1BC --- 2D6 --- 146 --- 040 --- 1CE
                      052 --- 040 --- 04A --- 1BC --- 2DD --- 146 --- 040 --- 1D3

                      How can I sort the columns so that they are as the first column?

                      Best regards,

                      Eric

                      _________________________________________________________________
                      FREE pop-up blocking with the new MSN Toolbar � get it now!
                      http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
                    • Peter Hodge
                      Hi Eric, I am assuming you want to re-order the columns horizontally, in which case Visual Block Mode is what you want. Press CTRL+V to start selecting a
                      Message 10 of 27 , Aug 3, 2006
                      • 0 Attachment
                        Hi Eric,

                        I am assuming you want to re-order the columns horizontally, in which case
                        Visual Block Mode is what you want. Press CTRL+V to start selecting a column,
                        use 'x' to delete it, and 'P' (upper-case P) to paste it (I find upper-case P
                        is more logical for Visual Block paste).

                        HTH,
                        regards,
                        Peter



                        --- Eric Leenman <eric.leenman@...> wrote:

                        > Hi,
                        >
                        > I have file which contains hexadecimal numbers like below:
                        >
                        > 04F --- 05F --- 052 --- 188 --- 2D4 --- 173 --- 040 --- 18D
                        > 051 --- 040 --- 05F --- 1CA --- 2E8 --- 14F --- 040 --- 1E2
                        > 051 --- 040 --- 069 --- 1B9 --- 2D7 --- 15E --- 040 --- 1A6
                        > 051 --- 040 --- 06F --- 1ED --- 2EB --- 12E --- 040 --- 209
                        > 051 --- 040 --- 078 --- 1F9 --- 2E3 --- 122 --- 040 --- 220
                        > 051 --- 045 --- 063 --- 1C8 --- 2D1 --- 146 --- 040 --- 1F4
                        > 051 --- 046 --- 05A --- 1BB --- 2D7 --- 158 --- 040 --- 1D3
                        > 051 --- 052 --- 04F --- 1B6 --- 2E3 --- 154 --- 040 --- 1BB
                        > 052 --- 040 --- 045 --- 1BC --- 2D6 --- 146 --- 040 --- 1CE
                        > 052 --- 040 --- 04A --- 1BC --- 2DD --- 146 --- 040 --- 1D3
                        >
                        > How can I sort the columns so that they are as the first column?
                        >
                        > Best regards,
                        >
                        > Eric
                        >
                        > _________________________________________________________________
                        > FREE pop-up blocking with the new MSN Toolbar  get it now!
                        > http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
                        >
                        >


                        Send instant messages to your online friends http://au.messenger.yahoo.com
                      • Eric Leenman
                        Hi Peter [snip] ... Sorry for not making my self clear. I want to re-order the columns vertical So column 1 is already OK, running from 04F ... ... 052 Column
                        Message 11 of 27 , Aug 3, 2006
                        • 0 Attachment
                          Hi Peter

                          [snip]
                          >I am assuming you want to re-order the columns horizontally, in which case

                          Sorry for not making my self clear.
                          I want to re-order the columns vertical
                          So column 1 is already OK, running from
                          04F
                          ...
                          ...
                          052

                          Column 2 should be
                          040
                          ...
                          040
                          045
                          046
                          052
                          05F


                          ect.


                          [snip]
                          > > I have file which contains hexadecimal numbers like below:
                          > >
                          > > 04F --- 05F --- 052 --- 188 --- 2D4 --- 173 --- 040 ---
                          >18D
                          > > 051 --- 040 --- 05F --- 1CA --- 2E8 --- 14F --- 040 ---
                          >1E2
                          > > 051 --- 040 --- 069 --- 1B9 --- 2D7 --- 15E --- 040 ---
                          >1A6
                          > > 051 --- 040 --- 06F --- 1ED --- 2EB --- 12E --- 040 ---
                          >209
                          > > 051 --- 040 --- 078 --- 1F9 --- 2E3 --- 122 --- 040 ---
                          >220
                          > > 051 --- 045 --- 063 --- 1C8 --- 2D1 --- 146 --- 040 ---
                          >1F4
                          > > 051 --- 046 --- 05A --- 1BB --- 2D7 --- 158 --- 040 ---
                          >1D3
                          > > 051 --- 052 --- 04F --- 1B6 --- 2E3 --- 154 --- 040 ---
                          >1BB
                          > > 052 --- 040 --- 045 --- 1BC --- 2D6 --- 146 --- 040 ---
                          >1CE
                          > > 052 --- 040 --- 04A --- 1BC --- 2DD --- 146 --- 040 ---
                          >1D3
                          > >
                          > > How can I sort the columns so that they are as the first column?
                          > >
                          [snip]

                          Rgds,
                          Eric

                          _________________________________________________________________
                          FREE pop-up blocking with the new MSN Toolbar � get it now!
                          http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
                        • Yakov Lerner
                          ... Dr. Chip s vis.vim plugin to the rescue, again (*1). Dr. Chip s plugin allows more than substitute-in- visual-blocks. It allows you to apply external shell
                          Message 12 of 27 , Aug 3, 2006
                          • 0 Attachment
                            On 8/3/06, Eric Leenman <eric.leenman@...> wrote:
                            > I have file which contains hexadecimal numbers like below:
                            >
                            > 04F --- 05F --- 052 --- 188 --- 2D4 --- 173 --- 040 --- 18D
                            > 051 --- 040 --- 05F --- 1CA --- 2E8 --- 14F --- 040 --- 1E2
                            > 051 --- 040 --- 069 --- 1B9 --- 2D7 --- 15E --- 040 --- 1A6
                            > 051 --- 040 --- 06F --- 1ED --- 2EB --- 12E --- 040 --- 209
                            > 051 --- 040 --- 078 --- 1F9 --- 2E3 --- 122 --- 040 --- 220
                            > 051 --- 045 --- 063 --- 1C8 --- 2D1 --- 146 --- 040 --- 1F4
                            > 051 --- 046 --- 05A --- 1BB --- 2D7 --- 158 --- 040 --- 1D3
                            > 051 --- 052 --- 04F --- 1B6 --- 2E3 --- 154 --- 040 --- 1BB
                            > 052 --- 040 --- 045 --- 1BC --- 2D6 --- 146 --- 040 --- 1CE
                            > 052 --- 040 --- 04A --- 1BC --- 2DD --- 146 --- 040 --- 1D3
                            >
                            > How can I sort the columns so that they are as the first column?

                            Dr. Chip's vis.vim plugin to the rescue, again (*1).
                            Dr. Chip's plugin allows more than substitute-in-
                            visual-blocks. It allows you to apply external shell command
                            to the visual block !, which is exactly what we need.

                            1. install Dr.Chip's visual operations plugin from
                            http://www.vim.org/scripts/script.php?script_id=1195
                            "vis : Extended Visual Mode Commands"

                            2. Ctrl-V and select the vertical column of numbers

                            3. type
                            :B ! sort
                            which appears on screen as
                            :'<,'>B !sort

                            Which sorts one vertical column !

                            Yakov

                            P.S. Incidentally, windows has external sort command, too.
                          • Eric Leenman
                            Yakov, Thanks, It works. Regards Eric [snip] ... [snip] _________________________________________________________________ Express yourself instantly with MSN
                            Message 13 of 27 , Aug 3, 2006
                            • 0 Attachment
                              Yakov,

                              Thanks,
                              It works.

                              Regards
                              Eric


                              [snip]
                              >
                              >Dr. Chip's vis.vim plugin to the rescue, again (*1).
                              >Dr. Chip's plugin allows more than substitute-in-
                              >visual-blocks. It allows you to apply external shell command
                              >to the visual block !, which is exactly what we need.
                              >
                              >1. install Dr.Chip's visual operations plugin from
                              > http://www.vim.org/scripts/script.php?script_id=1195
                              > "vis : Extended Visual Mode Commands"
                              >
                              >2. Ctrl-V and select the vertical column of numbers
                              >
                              >3. type
                              > :B ! sort
                              >which appears on screen as
                              > :'<,'>B !sort
                              >
                              >Which sorts one vertical column !
                              >
                              [snip]

                              _________________________________________________________________
                              Express yourself instantly with MSN Messenger! Download today - it's FREE!
                              http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
                            • Eric Leenman
                              Hi, I m using page-up and page-down to scroll. Also ctrl-home and ctrl-end. This moves the cursor to the beginning of the line. How can this be avoided. I need
                              Message 14 of 27 , Aug 3, 2006
                              • 0 Attachment
                                Hi,

                                I'm using page-up and page-down to scroll.
                                Also ctrl-home and ctrl-end.
                                This moves the cursor to the beginning of the line.
                                How can this be avoided.
                                I need to the cursor to stay where it is, as the lines are 1000+ characters
                                long

                                Rgds,
                                Eric

                                _________________________________________________________________
                                Is your PC infected? Get a FREE online computer virus scan from McAfee�
                                Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
                              • Peter Hodge
                                Hi, You can use CTRL-E and CTRL-Y to scroll up and down without moving the cursor. regards, Peter ... Send instant messages to your online friends
                                Message 15 of 27 , Aug 3, 2006
                                • 0 Attachment
                                  Hi,

                                  You can use CTRL-E and CTRL-Y to scroll up and down without moving the cursor.

                                  regards,
                                  Peter



                                  --- Eric Leenman <eric.leenman@...> wrote:

                                  > Hi,
                                  >
                                  > I'm using page-up and page-down to scroll.
                                  > Also ctrl-home and ctrl-end.
                                  > This moves the cursor to the beginning of the line.
                                  > How can this be avoided.
                                  > I need to the cursor to stay where it is, as the lines are 1000+ characters
                                  > long
                                  >
                                  > Rgds,
                                  > Eric
                                  >
                                  > _________________________________________________________________
                                  > Is your PC infected? Get a FREE online computer virus scan from McAfee®
                                  > Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
                                  >
                                  >


                                  Send instant messages to your online friends http://au.messenger.yahoo.com
                                • Yakov Lerner
                                  ... nmap :exe norm .winheight(0). j nmap :exe norm .winheight(0). k nmap :let
                                  Message 16 of 27 , Aug 3, 2006
                                  • 0 Attachment
                                    On 8/3/06, Eric Leenman <eric.leenman@...> wrote:
                                    > I'm using page-up and page-down to scroll.
                                    > Also ctrl-home and ctrl-end.
                                    > This moves the cursor to the beginning of the line.
                                    > How can this be avoided.
                                    > I need to the cursor to stay where it is, as the lines are 1000+ characters
                                    > long

                                    nmap <silent><PageDown> :exe "norm ".winheight(0)."j"<cr>
                                    nmap <silent><PageUp> :exe "norm ".winheight(0)."k"<cr>
                                    nmap <silent><c-home> :let x=col('.')<bar>1<bar>exe "norm ".x."<bar>"<cr>
                                    nmap <silent><c-end> :let x=col('.')<bar>$<bar>exe "norm ".x."<bar>"<cr>

                                    Yakov
                                    P.S. You can also try to add
                                    set ve=all
                                  • Jürgen Krämer
                                    Hi, ... Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact
                                    Message 17 of 27 , Aug 3, 2006
                                    • 0 Attachment
                                      Hi,

                                      Eric Leenman wrote:
                                      >
                                      > I'm using page-up and page-down to scroll.
                                      > Also ctrl-home and ctrl-end.
                                      > This moves the cursor to the beginning of the line.
                                      > How can this be avoided.

                                      :set nostartofline

                                      Regards,
                                      Jürgen

                                      --
                                      Sometimes I think the surest sign that intelligent life exists elsewhere
                                      in the universe is that none of it has tried to contact us. (Calvin)
                                    • Eric Leenman
                                      [snip] ... [snip] This works great. I m trying to map them also to visaul-mode but then I get the error: no range allowed Why is that? I have: vmap
                                      Message 18 of 27 , Aug 3, 2006
                                      • 0 Attachment
                                        [snip]
                                        >nmap <silent><PageDown> :exe "norm ".winheight(0)."j"<cr>
                                        >nmap <silent><PageUp> :exe "norm ".winheight(0)."k"<cr>
                                        >nmap <silent><c-home> :let x=col('.')<bar>1<bar>exe "norm ".x."<bar>"<cr>
                                        >nmap <silent><c-end> :let x=col('.')<bar>$<bar>exe "norm ".x."<bar>"<cr>
                                        [snip]

                                        This works great.

                                        I'm trying to map them also to visaul-mode but then I get the error:
                                        "no range allowed"
                                        Why is that?

                                        I have:

                                        vmap <silent><c-s-PageDown> :exe "norm ".winheight(0)."j"<cr>
                                        vmap <silent><c-s-PageUp> :exe "norm ".winheight(0)."k"<cr>
                                        vmap <silent><c-s-home> :let x=col('.')<bar>1<bar>exe "norm
                                        ".x."<bar>"<cr>
                                        vmap <silent><c-s-end> :let x=col('.')<bar>$<bar>exe "norm
                                        ".x."<bar>"<cr>

                                        Rgds,
                                        Eric

                                        _________________________________________________________________
                                        Express yourself instantly with MSN Messenger! Download today - it's FREE!
                                        http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
                                      • A.J.Mechelynck
                                        ... Hitting the : key in Visual mode causes the visual highlight to disappear, and Vim adds a range as :
                                        Message 19 of 27 , Aug 3, 2006
                                        • 0 Attachment
                                          Eric Leenman wrote:
                                          > [snip]
                                          >> nmap <silent><PageDown> :exe "norm ".winheight(0)."j"<cr>
                                          >> nmap <silent><PageUp> :exe "norm ".winheight(0)."k"<cr>
                                          >> nmap <silent><c-home> :let x=col('.')<bar>1<bar>exe "norm
                                          >> ".x."<bar>"<cr>
                                          >> nmap <silent><c-end> :let x=col('.')<bar>$<bar>exe "norm
                                          >> ".x."<bar>"<cr>
                                          > [snip]
                                          >
                                          > This works great.
                                          >
                                          > I'm trying to map them also to visaul-mode but then I get the error:
                                          > "no range allowed"
                                          > Why is that?
                                          >
                                          > I have:
                                          >
                                          > vmap <silent><c-s-PageDown> :exe "norm ".winheight(0)."j"<cr>
                                          > vmap <silent><c-s-PageUp> :exe "norm ".winheight(0)."k"<cr>
                                          > vmap <silent><c-s-home> :let x=col('.')<bar>1<bar>exe "norm
                                          > ".x."<bar>"<cr>
                                          > vmap <silent><c-s-end> :let x=col('.')<bar>$<bar>exe "norm
                                          > ".x."<bar>"<cr>
                                          >
                                          > Rgds,
                                          > Eric

                                          Hitting the : key in Visual mode causes the visual highlight to
                                          disappear, and Vim adds a "range" as :'<,'> which means "from the first
                                          to the last line of the latest Visual highlight".

                                          In this case you will want to clear the range before the Ex-command
                                          (e.g. by means of <C-U>, see ":help c_CTRL-U"); but restoring the
                                          highlight after scrolling (with "gv" q.v.) will move the cursor back to
                                          one end of the visual area, possibly canceling the scroll...

                                          You might prefer to set 'nostartofline' and then use <PageUp> and <PageDown>

                                          Best regards,
                                          Tony.
                                        • Eric Leenman
                                          Hi, With gv you can re-select the previous visual block. Is it possible to give a horizontal shift with it? Like + or - 5? Best Regards, Eric
                                          Message 20 of 27 , Aug 3, 2006
                                          • 0 Attachment
                                            Hi,

                                            With gv you can re-select the previous visual block.
                                            Is it possible to give a horizontal shift with it?
                                            Like + or - 5?

                                            Best Regards,
                                            Eric

                                            _________________________________________________________________
                                            On the road to retirement? Check out MSN Life Events for advice on how to
                                            get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
                                          • Tim Chase
                                            ... Natively? Not as far as I know. However, if you haven t already discovered the o command in block-wise-visual-mode, it does bounce you to the opposite
                                            Message 21 of 27 , Aug 3, 2006
                                            • 0 Attachment
                                              > With gv you can re-select the previous visual block. Is it
                                              > possible to give a horizontal shift with it? Like + or - 5?

                                              Natively? Not as far as I know. However, if you haven't already
                                              discovered the "o" command in block-wise-visual-mode, it does
                                              bounce you to the opposite corner of the block. Thus, you could
                                              do something like

                                              gv5lo5lo

                                              (that's "gee vee five ell oh five ell oh") or change the ells to
                                              "h" instead to shift left rather than right.

                                              Just something to try. I don't know how easily one could map it
                                              to a command that would take a count in visual mode. But that's
                                              at least a starting ground.

                                              You can read more at

                                              :help v_o

                                              -tim
                                            • A.J.Mechelynck
                                              ... You can indent or unindent visually selected lines with or
                                              Message 22 of 27 , Aug 3, 2006
                                              • 0 Attachment
                                                Eric Leenman wrote:
                                                > Hi,
                                                >
                                                > With gv you can re-select the previous visual block.
                                                > Is it possible to give a horizontal shift with it?
                                                > Like + or - 5?
                                                >
                                                > Best Regards,
                                                > Eric

                                                You can indent or unindent visually selected lines with > or < .
                                                However, IIUC this is a linewise (not blockwise) operation.


                                                Best regards,
                                                Tony.
                                              • Charles E Campbell Jr
                                                ... May I suggest looking at: http://vim.sourceforge.net/tips/tip.php?tip_id=588 : How to sort using visual blocks which discusses * how to sort visual-block
                                                Message 23 of 27 , Aug 3, 2006
                                                • 0 Attachment
                                                  Eric Leenman wrote:

                                                  > Hi,
                                                  >
                                                  > I have file which contains hexadecimal numbers like below:
                                                  >
                                                  > 04F --- 05F --- 052 --- 188 --- 2D4 --- 173 --- 040 --- 18D
                                                  > 051 --- 040 --- 05F --- 1CA --- 2E8 --- 14F --- 040 --- 1E2
                                                  > 051 --- 040 --- 069 --- 1B9 --- 2D7 --- 15E --- 040 --- 1A6
                                                  > 051 --- 040 --- 06F --- 1ED --- 2EB --- 12E --- 040 --- 209
                                                  > 051 --- 040 --- 078 --- 1F9 --- 2E3 --- 122 --- 040 --- 220
                                                  > 051 --- 045 --- 063 --- 1C8 --- 2D1 --- 146 --- 040 --- 1F4
                                                  > 051 --- 046 --- 05A --- 1BB --- 2D7 --- 158 --- 040 --- 1D3
                                                  > 051 --- 052 --- 04F --- 1B6 --- 2E3 --- 154 --- 040 --- 1BB
                                                  > 052 --- 040 --- 045 --- 1BC --- 2D6 --- 146 --- 040 --- 1CE
                                                  > 052 --- 040 --- 04A --- 1BC --- 2DD --- 146 --- 040 --- 1D3
                                                  >
                                                  > How can I sort the columns so that they are as the first column?

                                                  May I suggest looking at:

                                                  http://vim.sourceforge.net/tips/tip.php?tip_id=588 : "How to sort using
                                                  visual blocks"

                                                  which discusses

                                                  * how to sort visual-block selected columns (independently of
                                                  surrounding text), and
                                                  * how to sort lines based on the contents of a visual-block selected
                                                  columns.

                                                  Regards,
                                                  Chip Campbell
                                                • Charles E Campbell Jr
                                                  ... Hello! Perhaps :set ve=all nosol will get you the behavior you want. Regards, Chip Campbell
                                                  Message 24 of 27 , Aug 3, 2006
                                                  • 0 Attachment
                                                    Eric Leenman wrote:

                                                    > I'm using page-up and page-down to scroll.
                                                    > Also ctrl-home and ctrl-end.
                                                    > This moves the cursor to the beginning of the line.
                                                    > How can this be avoided.
                                                    > I need to the cursor to stay where it is, as the lines are 1000+
                                                    > characters long

                                                    Hello!

                                                    Perhaps :set ve=all nosol

                                                    will get you the behavior you want.

                                                    Regards,
                                                    Chip Campbell
                                                  • Ben K.
                                                    ... Could you cut away the finished block and paste to another place, and do gv again? Not quite reliable, but may work. Regards, Ben K. Developer
                                                    Message 25 of 27 , Aug 3, 2006
                                                    • 0 Attachment
                                                      > With gv you can re-select the previous visual block.
                                                      > Is it possible to give a horizontal shift with it?
                                                      > Like + or - 5?

                                                      Could you cut away the finished block and paste to another place, and do
                                                      gv again? Not quite reliable, but may work.


                                                      Regards,

                                                      Ben K.
                                                      Developer
                                                      http://benix.tamu.edu
                                                    • Charles E Campbell Jr
                                                      ... Do you mean to move a selected block horizontally, or to have the same visual block selection geometry shift? Regards, Chip Campbell
                                                      Message 26 of 27 , Aug 3, 2006
                                                      • 0 Attachment
                                                        Eric Leenman wrote:

                                                        > With gv you can re-select the previous visual block.
                                                        > Is it possible to give a horizontal shift with it?
                                                        > Like + or - 5?


                                                        Do you mean to move a selected block horizontally, or to have the same
                                                        visual block selection geometry shift?

                                                        Regards,
                                                        Chip Campbell
                                                      Your message has been successfully submitted and would be delivered to recipients shortly.