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

Re: How do I ensure a line is present only once?

Expand Messages
  • Ron Aaron
    ... This works for me: line 1 will not match: normal mq1G %s/== linetomatch ==/==!@#$!@$==/e if we changed pos, the line existed if line( . ) != 1 revert
    Message 1 of 2 , Jan 13, 2000
    • 0 Attachment
      Ron Aaron <v-ronaar@...> writes:
      >Hi all --
      >
      >I'm running into a small problem with some scripts. I want to make sure a
      >certain line is present in a buffer only once.
      >

      This works for me:
      " line 1 will not match:
      normal mq1G
      %s/== linetomatch ==/==!@#$!@$==/e
      " if we changed pos, the line existed
      if line(".") != 1
      " revert change
      u
      else
      " put new line
      $ put='== linetomatch =='
      endif
    Your message has been successfully submitted and would be delivered to recipients shortly.