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

Re:

Expand Messages
  • vim@...
    ... If you re using the generic / search (which it appears you re doing), you can disable wrapscan to prevent vim from wrapping back to the beginning. ...
    Message 1 of 2 , Feb 2, 2013
    • 0 Attachment
      On Sat, 2 Feb 2013 14:21:54 -0800, Andy Richer wrote:
      > Hi vim experts:
      >
      > I use keyboard macro for following sample contents:
      >
      > aaa/bbb/kp0/qqq 1.553 rp-+
      >
      > ccc/ddd 1.235 -0.043 0.274 -0.007 rp-+
      >
      >
      >
      > aaa/bbb/ake/qqq 1.552 rp-+
      >
      > vcc1/ddd 1.235 -0.043 0.274 -0.021 rp-+
      >
      >
      > ..........
      >
      > my keyboard macro like this sequence:
      > qa
      > /-+
      > J
      > j
      > q
      >
      > So I join 2 lines together like this: aaa/bbb/kp0/qqq 1.553
      > rp-+ccc/ddd 1.235 -0.043 0.274 -0.007
      > rp-+ I know I can use 5@a, 6@a ......., yet it is difficult for me
      > to decide the number for @a in a big file.
      > If I give number too big, @a will reach end of file then start from
      > beginning of file until number of @a finished, and this cause
      > problem.
      >
      > My 2 questions:
      > 1. is there a way to tell vim when reach end of file, just stop @a ?

      If you're using the generic "/" search (which it appears you're
      doing), you can disable 'wrapscan' to prevent vim from wrapping back
      to the beginning.

      :set nowrapscan
      :help 'wrapscan'

      > 2. is there a way to tell vim to stop @a at specific line number?
      > say line 500

      You could possibly do a check if the line-number happens to be [equal
      to|greater than|less than] a given line number and then raise an
      exception which should kill the macro.

      Another alternative would be to use an Ex command to do the work for
      you. Something like:

      :g/-+/j

      which can then be limited with

      :1,400g/-+/j

      to only do the joining on lines 1-400 (or whatever arbitrary range
      you specify).

      -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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    Your message has been successfully submitted and would be delivered to recipients shortly.