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

Re: column selection/column editing

Expand Messages
  • Tony Mechelynck
    ... To select a rectangle of text, use Ctrl-V (or Ctrl-Q if you have mapped Ctrl-V to the paste operation) instead of v. Moving the cursor verically is done,
    Message 1 of 9 , Oct 1, 2008
    • 0 Attachment
      On 02/10/08 02:47, reviol@... wrote:
      > Hi!
      >
      > I would like to edit a column in an ascii file (an ascii file with numbers).
      > The first step would be, I guess, selecting the column via visual selection
      > "v". After switching to "v", I'm not able to move down the cursor
      > vertically, in order to make the selection I intend to do. What is the
      > trick?
      >
      > Walter

      To select a rectangle of text, use Ctrl-V (or Ctrl-Q if you have mapped
      Ctrl-V to the paste operation) instead of v. Moving the cursor verically
      is done, as always, using j k (or <Down> <Up>) for small motions, other
      commands for larger motions, see

      :help blockwise-visual
      :help up-down-motions

      Best regards,
      Tony.
      --
      hundred-and-one symptoms of being an internet addict:
      193. You ask your girlfriend to drive home so you can sit back with
      your PDA and download the information to your laptop

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • reviol@wuchem.wustl.edu
      Thanks, Richard! Now comes part two of the exercise. See example below: 6.5 53.94 8.6 34.44 10.7 12.94 12.8 -2.25 14.9 -8.67 16.0 -8.20 18.1 -4.92
      Message 2 of 9 , Oct 1, 2008
      • 0 Attachment
        Thanks, Richard!

        Now comes part two of the exercise. See example below:

        6.5 53.94
        8.6 34.44
        10.7 12.94
        12.8 -2.25
        14.9 -8.67
        16.0 -8.20
        18.1 -4.92

        12345678901234

        I'm still in the visual mode. And I have selected, say, the column 7.
        Now I would like to replace each number in colum 7 by "3".

        Colon brings me to the command line, which appears now as :'<,'>
        I know the substitute command quite well, I guess, namely from "line
        editing". But how to make the susbtitution in this specific example?

        Note that I looked up Tip 438 in vim.wikia, which is related to my
        problem, but unclear in the description of the steps.

        Regards,
        Walter


        Quoting Richard Hartmann <richih.mailinglist@...>:

        >
        > On Thu, Oct 2, 2008 at 02:47, <reviol@...> wrote:
        >
        >> What is the
        >> trick?
        >
        > ctrl-v
        >
        >
        > Richard
        >
        > >
        >
        >



        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • David Lam
        hmm probably an easier way would be to not go into ex and just hit r3 (i.e. replace the visual block with 3!) ...
        Message 3 of 9 , Oct 1, 2008
        • 0 Attachment
          hmm probably an easier way would be to not go into ex and just hit "r3"  (i.e. replace the visual block with 3!)

          On Wed, Oct 1, 2008 at 6:20 PM, <reviol@...> wrote:

          Thanks, Richard!

          Now comes part two of the exercise. See example below:

              6.5  53.94
              8.6  34.44
             10.7  12.94
             12.8  -2.25
             14.9  -8.67
             16.0  -8.20
             18.1  -4.92

          12345678901234

          I'm still in the visual mode. And I have selected, say, the column 7.
          Now I would like to replace each number in colum 7 by "3".

          Colon brings me to the command line, which appears now as :'<,'>
          I know the substitute command quite well, I guess, namely from "line
          editing". But how to make the susbtitution in this specific example?

          Note that I looked up Tip 438 in vim.wikia, which is related to my
          problem, but unclear in the description of the steps.

          Regards,
          Walter


          Quoting Richard Hartmann <richih.mailinglist@...>:

          >
          > On Thu, Oct 2, 2008 at 02:47,  <reviol@...> wrote:
          >
          >> What is the
          >> trick?
          >
          > ctrl-v
          >
          >
          > Richard
          >
          > >
          >
          >






          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---

        • Tony Mechelynck
          ... See ... To replace all characters in a given column by the digit 3: 1. block-select (with Ctrl-V + cursor movement) 2. A3 3. re-select with gv 4.
          Message 4 of 9 , Oct 1, 2008
          • 0 Attachment
            On 02/10/08 03:20, reviol@... wrote:
            > Thanks, Richard!
            >
            > Now comes part two of the exercise. See example below:
            >
            > 6.5 53.94
            > 8.6 34.44
            > 10.7 12.94
            > 12.8 -2.25
            > 14.9 -8.67
            > 16.0 -8.20
            > 18.1 -4.92
            >
            > 12345678901234
            >
            > I'm still in the visual mode. And I have selected, say, the column 7.
            > Now I would like to replace each number in colum 7 by "3".
            >
            > Colon brings me to the command line, which appears now as :'<,'>
            > I know the substitute command quite well, I guess, namely from "line
            > editing". But how to make the susbtitution in this specific example?
            >
            > Note that I looked up Tip 438 in vim.wikia, which is related to my
            > problem, but unclear in the description of the steps.
            >
            > Regards,
            > Walter
            >
            >
            > Quoting Richard Hartmann<richih.mailinglist@...>:
            >
            >> On Thu, Oct 2, 2008 at 02:47,<reviol@...> wrote:
            >>
            >>> What is the
            >>> trick?
            >> ctrl-v
            >>
            >>
            >> Richard

            See
            :help v_b_I
            :help v_b_A
            :help gv

            To replace all characters in a given column by the digit 3:

            1. block-select (with Ctrl-V + cursor movement)

            2. A3<Esc>

            3. re-select with gv

            4. delete with d or <Del>

            _OR_

            :'<,'>s/\%7v./3/

            (replaces one character in virtual column 7 by a 3 in all lines
            previously highlighted).


            Best regards,
            Tony.
            --
            The Kennedy Constant:
            Don't get mad -- get even.

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Charles E. Campbell, Jr.
            ... You can get vis.vim from: http://vim.sourceforge.net/scripts/script.php?script_id=1195 (stable) http://mysite.verizon.net/astronaut/vim/index.html#VIS
            Message 5 of 9 , Oct 1, 2008
            • 0 Attachment
              reviol@... wrote:
              > Thanks, Richard!
              >
              > Now comes part two of the exercise. See example below:
              >
              > 6.5 53.94
              > 8.6 34.44
              > 10.7 12.94
              > 12.8 -2.25
              > 14.9 -8.67
              > 16.0 -8.20
              > 18.1 -4.92
              >
              > 12345678901234
              >
              > I'm still in the visual mode. And I have selected, say, the column 7.
              > Now I would like to replace each number in colum 7 by "3".
              >
              You can get vis.vim from:

              http://vim.sourceforge.net/scripts/script.php?script_id=1195 (stable)
              http://mysite.verizon.net/astronaut/vim/index.html#VIS
              (cutting edge)

              Using vis.vim:

              ctrl-v, move to select column, :B s/./3/

              Regards,
              Chip Campbell


              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Gary Johnson
              ... That s easy: with that column selected, just type r3 For a list of the operators you can use in visual mode, see ... Regards, Gary
              Message 6 of 9 , Oct 2, 2008
              • 0 Attachment
                On 2008-10-01, reviol@... wrote:
                > Thanks, Richard!
                >
                > Now comes part two of the exercise. See example below:
                >
                > 6.5 53.94
                > 8.6 34.44
                > 10.7 12.94
                > 12.8 -2.25
                > 14.9 -8.67
                > 16.0 -8.20
                > 18.1 -4.92
                >
                > 12345678901234
                >
                > I'm still in the visual mode. And I have selected, say, the column 7.
                > Now I would like to replace each number in colum 7 by "3".

                That's easy: with that column selected, just type

                r3

                For a list of the operators you can use in visual mode, see

                :help visual-operators

                Regards,
                Gary


                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • John Beckett
                ... Tip 438 is quite good, but I see what you mean: http://vim.wikia.com/wiki/Search_and_replace_in_a_visual_selection In the Substituting in a visual
                Message 7 of 9 , Oct 2, 2008
                • 0 Attachment
                  reviol wrote:
                  > Now I would like to replace each number in colum 7 by "3".
                  >...
                  > Note that I looked up Tip 438 in vim.wikia, which is related
                  > to my problem, but unclear in the description of the steps.

                  Tip 438 is quite good, but I see what you mean:
                  http://vim.wikia.com/wiki/Search_and_replace_in_a_visual_selection

                  In the "Substituting in a visual selection" section I made it a bit easy for myself
                  by giving a single-line example. The :s/\%Vxx/yy/g command only operates on the
                  current line. When working over several lines, you need to specify a range. Using
                  :%s/\%Vxx/yy/g would work.

                  In your case, you want to match any character, so 'xx' is '.', and you want to
                  replace it with '7', so 'yy' is '7'. So, select the area with Ctrl-V (or perhaps
                  Ctrl-Q), press Escape to remove the selection, then enter:

                  :%s/\%V./7/g

                  I know better solutions have been given for this particular example, but the above
                  will handle a general substitute.

                  Now someone has to edit the tip...

                  John


                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                Your message has been successfully submitted and would be delivered to recipients shortly.