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

Editing contents of a register?

Expand Messages
  • Rostyslaw Lewyckyj
    Suppose that I have a collection of editing commands such as %g/pattern_a/ %g/pattern_b/ %g/pattern_c/ ........................ that find and list all the
    Message 1 of 3 , Feb 28, 2011
    • 0 Attachment
      Suppose that I have a collection of editing commands such as
      %g/pattern_a/
      %g/pattern_b/
      %g/pattern_c/
      ........................
      that find and list all the lines of a file that satisfy some patterns.
      After I visually inspect a given list of lines, I may want to delete them.

      I have thought to do this as follows:
      -- yank a list command into a register "ayy
      -- execute the command :@a"
      -- inspect the lines as they are listed

      Then if I'd now like to delete this set of lines, I'd like to append a d
      to the contents of register a changing it from a list to a delete command,
      and execute the command.

      So how do I _easily_ modify, edit, the contents of a register?

      I'd like something simpler than loading a list command into the clipboard
      via highlighting and ^C followed by :^V and if choosing to delete
      then :^Vd ???
      --
      Rostyk

      --
      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
    • Ben Schmidt
      ... You can enter any register onto the commandline by using ^R, so just do this if you want (after pressing a, the contents of the register will appear on the
      Message 2 of 3 , Feb 28, 2011
      • 0 Attachment
        On 1/03/11 12:49 PM, Rostyslaw Lewyckyj wrote:
        > Suppose that I have a collection of editing commands such as
        > %g/pattern_a/
        > %g/pattern_b/
        > %g/pattern_c/
        > ........................
        > that find and list all the lines of a file that satisfy some patterns.
        > After I visually inspect a given list of lines, I may want to delete them.
        >
        > I have thought to do this as follows:
        > -- yank a list command into a register "ayy
        > -- execute the command :@a"
        > -- inspect the lines as they are listed
        >
        > Then if I'd now like to delete this set of lines, I'd like to append a d
        > to the contents of register a changing it from a list to a delete command,
        > and execute the command.
        >
        > So how do I _easily_ modify, edit, the contents of a register?
        >
        > I'd like something simpler than loading a list command into the clipboard
        > via highlighting and ^C followed by :^V and if choosing to delete
        > then :^Vd ???

        You can enter any register onto the commandline by using ^R, so just do
        this if you want (after pressing a, the contents of the register will
        appear on the commandline)

        :^Rad

        If you prefer, you could issue a command to append a d to the register
        and then execute the modified register

        :let @a.="d"
        :@a

        And there are other possibilities too....

        Ben.



        --
        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
      • Tim Chase
        ... I ve done something like this in the past where I ve modified my buffer such as you have with ... which leaves the buffer looking like ... ... with leading
        Message 3 of 3 , Feb 28, 2011
        • 0 Attachment
          On 02/28/2011 07:49 PM, Rostyslaw Lewyckyj wrote:
          > Suppose that I have a collection of editing commands such as
          > %g/pattern_a/
          > %g/pattern_b/
          > %g/pattern_c/
          > ........................
          > that find and list all the lines of a file that satisfy some patterns.
          > After I visually inspect a given list of lines, I may want to delete them.
          >
          > I have thought to do this as follows:
          > -- yank a list command into a register "ayy
          > -- execute the command :@a"
          > -- inspect the lines as they are listed
          >
          > Then if I'd now like to delete this set of lines, I'd like to append a d
          > to the contents of register a changing it from a list to a delete command,
          > and execute the command.
          >
          > So how do I _easily_ modify, edit, the contents of a register?
          >
          > I'd like something simpler than loading a list command into the clipboard
          > via highlighting and ^C followed by :^V and if choosing to delete
          > then :^Vd ???

          I've done something like this in the past where I've modified my
          buffer such as you have with

          :%s/.*/:&d

          which leaves the buffer looking like

          :%g/pattern_a/d
          :%g/pattern_b/d
          ...

          with leading colons and trailing "d" commands.

          You can then yank that entire buffer's contents and execute it as
          a macro:

          :%y
          @"

          or if you want to name it,

          :%ya
          @a

          You can also modify registers by using the "@" notation:

          :let @a='hello' . @a . 'world'

          -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
        Your message has been successfully submitted and would be delivered to recipients shortly.