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

combine ":e file" and ":30,40y"

Expand Messages
  • Oliver Fuchs
    Hi, often I have to reply to an email and put parts of a file named /home/me/file in that email. ... Now I switch back to the email again with keyboard-command
    Message 1 of 4 , Dec 3, 2004
    • 0 Attachment
      Hi,

      often I have to reply to an email and put parts of a file named
      /home/me/file in that email.

      So in mutt I reply to the email, mutt starts vim to edit the email and I do:
      :e /home/me/file
      Now vim opens this file and here I do:
      :30,40y
      Now I switch back to the email again with keyboard-command
      "Strg ^"
      and insert the yanked lines in my email.

      I would like to know if it is possible to put these two steps in one with
      something like
      :e /home/me/file and 30,40y

      I am not sure where to look in the help or if it is even possible?

      Thanx in advance

      Oliver
      --
      ... don't touch the bang bang fruit
    • Tim Chase
      ... While I don t know what your Strg ^ call does above and beyond :e # , the following ... what you describe. If Strg ^ does something magicomistico
      Message 2 of 4 , Dec 3, 2004
      • 0 Attachment
        > So in mutt I reply to the email, mutt starts vim to edit the
        > email and I do:
        > :e /home/me/file
        > Now vim opens this file and here I do:
        > :30,40y
        > Now I switch back to the email again with keyboard-command
        > "Strg ^"
        > and insert the yanked lines in my email.
        >
        > I would like to know if it is possible to put these two steps
        > in one with something like
        > :e /home/me/file and 30,40y

        While I don't know what your "Strg ^" call does above and beyond
        ":e #", the following

        :e /home/me/file | 30,40y | e #

        what you describe.

        If "Strg ^" does something magicomistico beyond just returning to
        the previous file, you should be able to just replace the "e #"
        with your call like

        e /home/me/file | 30,40y | Strg ^

        You can read more at

        :help :bar
        :he cmdline-special

        which (1) shows how to chain commands together like you want, and
        (2) details on using the "#" to edit the "alternate file".

        As a completely diff. solution, if you've got sed on hand, you
        could do something like

        :$r! sed -n "30,40p" < /home/me/file

        if you want to read the contents of /home/me/file(lines 30-40)
        into the current file at the end. If you want it elsewhere, you
        can easily modify the "$" (EOF) to be something else like a fixed
        line:

        :10r! sed -n "30,40p" < /home/me/file

        or after the first blank line:

        :1/^\s*$/r! sed -n "30,40p" < /home/me/file

        or other such Ex positioning fun :)

        Hope this helps,

        -tim
      • Oliver Fuchs
        ... I can use the vim-keyboard shortcut Strg ^ - and that is german and stands for the combination: Ctrl ^ Sorry for this. ... Yes, and now that I am
        Message 3 of 4 , Dec 3, 2004
        • 0 Attachment
          On Fri, 03 Dec 2004, Tim Chase wrote:

          > >So in mutt I reply to the email, mutt starts vim to edit the
          > >email and I do:
          > > :e /home/me/file
          > > Now vim opens this file and here I do:
          > > :30,40y
          > > Now I switch back to the email again with keyboard-command
          > > "Strg ^"
          > > and insert the yanked lines in my email.
          > >I would like to know if it is possible to put these two steps
          > >in one with something like
          > >:e /home/me/file and 30,40y
          >
          > While I don't know what your "Strg ^" call does above and beyond
          > ":e #", the following
          > :e /home/me/file | 30,40y | e #
          > what you describe.
          > If "Strg ^" does something magicomistico beyond just returning to
          > the previous file, you should be able to just replace the "e #"
          > with your call like

          Ah yes, my fault it means instead of using the ex-command:
          :e #
          I can use the vim-keyboard shortcut "Strg ^" - and that is german and stands
          for the combination:
          "Ctrl ^"
          Sorry for this.

          So the combination has to be:

          :e /home/me/file | 30,40y| e #

          Yes, and now that I am typing this I read exactly the answer of my question
          in my book "Learning the vi-Editor". I think it is too late to do something
          where I need a brain for ... or am I only lonely. Sorry for this.

          > :help :bar
          > :he cmdline-special

          I will learn this by heart.

          >
          > which (1) shows how to chain commands together like you want, and
          > (2) details on using the "#" to edit the "alternate file".
          > As a completely diff. solution, if you've got sed on hand, you
          > could do something like
          > :$r! sed -n "30,40p" < /home/me/file
          > if you want to read the contents of /home/me/file(lines 30-40)
          > into the current file at the end. If you want it elsewhere, you
          > can easily modify the "$" (EOF) to be something else like a fixed
          > line:
          > :10r! sed -n "30,40p" < /home/me/file
          > or after the first blank line:
          > :1/^\s*$/r! sed -n "30,40p" < /home/me/file
          > or other such Ex positioning fun :)
          This goes to my knowledge folder - this is real Ex-fun
          >
          > Hope this helps,

          That was more than just a help ... many, many thanks for your detailed
          answers. And sorry for my distraction.

          Oliver
          --
          ... don't touch the bang bang fruit
        • Tim Chase
          ... Ah...My turn to file something in my knowledge folder ... [light goes on] so you can just forego the | e # bit of things, and just use ye olde ctrl+^
          Message 4 of 4 , Dec 3, 2004
          • 0 Attachment
            > I can use the vim-keyboard shortcut "Strg ^" - and that is
            > german and stands for the combination:
            > "Ctrl ^"

            Ah...My turn to file something in my knowledge folder

            > So the combination has to be:
            >
            > :e /home/me/file | 30,40y| e #

            [light goes on] so you can just forego the "| e #" bit of things,
            and just use ye olde ctrl+^ instead if you prefer.

            >> :help :bar
            >> :he cmdline-special
            >
            >
            > I will learn this by heart.

            Heh, if you learn all the conditions in which the bar is
            interpreted versus when it's not (or at least the germane
            commands), you're a step ahead of me...I try it, and if it
            doesn't work, I have to run it through an exec() call instead.
            Same with when "#" is expanded and when it's not. All very
            trial-and-error for me :)

            > This goes to my knowledge folder - this is real Ex-fun

            Ah, the joy of ex ;)

            > And sorry for my distraction.

            Not a problem at all.

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