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

execute key strokes from a file

Expand Messages
  • Peng Yu
    Hi, I m wondering if there is a way to execute key strokes from a file. For example, I want to open a file main.vim, then type i, CTRL-R, %, which type the
    Message 1 of 3 , Dec 10, 2012
    • 0 Attachment
      Hi,

      I'm wondering if there is a way to execute key strokes from a file.

      For example, I want to open a file main.vim, then type i, CTRL-R, %,
      which type the filename main.vim in the file. The I type ESC and :wq
      to save the file and quit. Is there a way to automate the whole
      process in a script?

      Regards,
      Peng

      --
      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
    • Marcin Szamotulski
      ... I am not sure if this is what you want: you can use :argdo (or :windo, ... There to type you need to press ^V^R (i.e. CTRL-V followed by CTRL-R), to
      Message 2 of 3 , Dec 10, 2012
      • 0 Attachment
        On 09:33 Mon 10 Dec , Peng Yu wrote:
        > Hi,
        >
        > I'm wondering if there is a way to execute key strokes from a file.
        >
        > For example, I want to open a file main.vim, then type i, CTRL-R, %,
        > which type the filename main.vim in the file. The I type ESC and :wq
        > to save the file and quit. Is there a way to automate the whole
        > process in a script?
        >
        > Regards,
        > Peng
        >
        > --
        > 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

        I am not sure if this is what you want: you can use :argdo (or :windo,
        :bufdo - what fit you better) with

        :argdo normal i %
        :wa

        There to type you need to press ^V^R (i.e. CTRL-V followed by
        CTRL-R), to type you need ^V<Esc> (i.e. CTRL-V followed by the <Esc>
        key).

        Best,
        Marcin

        --
        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 Fritz
        ... Yes, there is. See :help :source. If you use :source! the file is read as if typed from normal mode. If you use :source the file is read as a series of
        Message 3 of 3 , Dec 10, 2012
        • 0 Attachment
          On Monday, December 10, 2012 11:33:36 AM UTC-6, Peng Yu wrote:
          >
          > I'm wondering if there is a way to execute key strokes from a file.
          >

          Yes, there is.

          See :help :source. If you use ":source!" the file is read as if typed from normal mode. If you use ":source" the file is read as a series of ex commands.

          See :help -w for how to create such a file.

          You can also record a macro to do all the actions you want and run the macro in a bufdo or windo or tabdo command. I do this from time to time when I want to repeat a bunch of commands on a bunch of files.

          --
          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.