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

Re: column selection/column editing

Expand Messages
  • 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 1 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 2 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.