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

Vim7 buf modify functions?

Expand Messages
  • Eric Arnold
    - Is there any way to do a setbufline() as with the new getbufline() ? It would be *great* to be able to change a buffer without having to load it into a
    Message 1 of 5 , Apr 3, 2006
    • 0 Attachment
      - Is there any way to do a setbufline() as with the new getbufline() ? It
      would be *great* to be able to change a buffer without having to load it into a
      window.

      - It would be helpful if setline() would operate like other splicing
      functions, i.e. setline( expr, list, start, stop ) where it would basically
      remove the lines between start and stop, and insert the lines from the list.
      If it worked this way, it would take the place of:

      - where is the deletebufline() functionality? I can't seem to find out how
      to remove lines from a buffer via the function interface. I'd like to avoid
      silent 1,$ d
      because of all the side effects with registers, and messages that show up in
      the command window regardless of "silent" (i.e. "### fewer lines" ).
    • jagpreet
      Hi All, Is there anyway I can add prefix to some of the variables in a file with some specific text. I know the global replacement command, but the number of
      Message 2 of 5 , Apr 3, 2006
      • 0 Attachment
        Hi All,
        Is there anyway I can add prefix to some of the variables in a file with
        some specific text.
        I know the global replacement command, but the number of variables are
        really huge and putting global replacement individually for each variable
        will take long time.

        I want to add text prefix XXX to all some variables in the file.

        ~Regards~
        Jagpreet
      • Yakov Lerner
        ... If there is *small* number of variables for which you don t need ... and then proceed to remove prefix where you don t need it. Otherwise, if you can come
        Message 3 of 5 , Apr 3, 2006
        • 0 Attachment
          On 4/3/06, jagpreet <jagpreetc@...> wrote:
          > Is there anyway I can add prefix to some of the variables in a file with
          > some specific text.
          > I know the global replacement command, but the number of variables are
          > really huge
          If there is *small* number of variables for which you don't need
          prefix, then you may consider adding prefix for all variables:
          :%s/\w\+/PREFIX&/g
          and then proceed to remove prefix where you don't need it.

          Otherwise, if you can come up with regexp for those variables
          which you want to replace, then its's easy too.

          Otherwise you'll still need to prepare list of variables and then it's
          easy to make a function that takes this list from, say,
          external file, and work according to the list. I don't know
          which way you choose.

          Yakov

          and putting global replacement individually for each variable

          > will take long time.
          >
          > I want to add text prefix XXX to all some variables in the file.
        • jagpreet
          Thanks for reply Yakov. Well There are huge number of variables for which I need chages and again lotsa variable where I don t the prfix. Also, I don t know
          Message 4 of 5 , Apr 3, 2006
          • 0 Attachment
            Thanks for reply Yakov.

            Well There are huge number of variables for which I need chages and again
            lotsa variable where I don't the prfix.
            Also, I don't know about the "regexp" which you mentioned.
            I'm not good at script programming otherwise I thogut I can list all
            variables in a file and can replce them with the prfix to the actual file.

            Also I must mention I was using some library where all the variables were
            with the same name, but because of some version complexity we are prefixing
            every variable with the version number and so I need this facility.
            I'm compiling the cpp file in gcc is there anyway I can use some compiler
            facility of vim.

            Looking forward to here a little more on the same.

            Jagpreet

            -----Original Message-----
            From: Yakov Lerner [mailto:iler.ml@...]
            Sent: Monday, April 03, 2006 3:24 PM
            To: jagpreetc@...
            Cc: Vim mailing list
            Subject: Re: adding prefix

            On 4/3/06, jagpreet <jagpreetc@...> wrote:
            > Is there anyway I can add prefix to some of the variables in a file with
            > some specific text.
            > I know the global replacement command, but the number of variables are
            > really huge
            If there is *small* number of variables for which you don't need
            prefix, then you may consider adding prefix for all variables:
            :%s/\w\+/PREFIX&/g
            and then proceed to remove prefix where you don't need it.

            Otherwise, if you can come up with regexp for those variables
            which you want to replace, then its's easy too.

            Otherwise you'll still need to prepare list of variables and then it's
            easy to make a function that takes this list from, say,
            external file, and work according to the list. I don't know
            which way you choose.

            Yakov

            and putting global replacement individually for each variable

            > will take long time.
            >
            > I want to add text prefix XXX to all some variables in the file.
          • Yegappan Lakshmanan
            Hello, ... You can delete the lines to the black-hole register: 1,$ d_ For more information, read ... You can set the report option to a large value to
            Message 5 of 5 , Apr 3, 2006
            • 0 Attachment
              Hello,

              On 4/3/06, Eric Arnold <eric_p_arnold@...> wrote:
              >
              > - Is there any way to do a setbufline() as with the new getbufline() ? It
              > would be *great* to be able to change a buffer without having to load it into a
              > window.
              >
              > - It would be helpful if setline() would operate like other splicing
              > functions, i.e. setline( expr, list, start, stop ) where it would basically
              > remove the lines between start and stop, and insert the lines from the list.
              > If it worked this way, it would take the place of:
              >
              > - where is the deletebufline() functionality? I can't seem to find out how
              > to remove lines from a buffer via the function interface. I'd like to avoid
              > silent 1,$ d
              > because of all the side effects with registers,
              >

              You can delete the lines to the black-hole register:

              1,$ d_

              For more information, read

              :help quote_

              >
              > and messages that show up in the command window regardless
              > of "silent" (i.e. "### fewer lines" ).
              >

              You can set the 'report' option to a large value to prevent the messages:

              let old_report = &report
              set report=9999
              1,$ d_
              let &report=old_report

              For more information, read

              :help 'report'

              - Yegappan
            Your message has been successfully submitted and would be delivered to recipients shortly.