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

Re: Is this Possible with Vim Macros?

Expand Messages
  • Rik Herrin
    Thanks a lot for your input. Now only if it can be converted a perl script, then you could use vim to quickly hack scripts and deploy them anywhere even if
    Message 1 of 6 , Jan 1, 2006
      Thanks a lot for your input. Now only if it can be
      converted a perl script, then you could use vim to
      quickly hack scripts and deploy them anywhere even if
      there is no vim installed :D

      PS. By the way, do you know of any good vim scripting
      example sites where I can learn vim scripting? Thanks
      for your time.

      --- Tim Chase <vim@...> wrote:

      > > However, I was wondering if there was any way to
      > use
      > > vim's macros from the bash shell or from my bash
      > > scripts. Is there any way to lanuch vim in the
      > > background using bash and execute macros on files
      > in
      > > this way? If not, is there any way to convert a
      > vim
      > > macro into a perl script that you can then use
      > from
      > > the bash shell to operate on a large number of
      > files?
      >
      > A common solution to this is to put your desired Vim
      > commands in script
      > file, with "wq" (or "wq!" or "wqa!", or however you
      > want to save
      > whatever results you've created).
      >
      > Then, you can launch vim with
      >
      > vim -s script.txt somefile.txt
      >
      > If you're using gvim, you may want to prevent it
      > from forking into a
      > background process by adding the "-f" parameter:
      >
      > vim -f -s script.txt somefile.txt
      >
      > Vim is also smart enough to read from stdin, so you
      > can have something like
      >
      > cat *.bork | vim -s script.txt -
      >
      > IIRC, this assumes non-fork mode and sets it for
      > you.
      >
      > If you want to semi-interactively edit a whole bunch
      > of files, you may
      > also be looking for vim's argdo/bufdo/windo
      > functionality which allows
      > you to run an Ex command (or commands) across all
      > your loaded
      > arguments/buffers/windows. Thus, you could do
      > something like
      >
      > bash> ls *.blah | wc -l
      > 314
      > bash> vi *.blah
      >
      > and then execute
      >
      > :set hidden
      > :argdo %s/foo/bar/g
      > (optionally look at some resulting files to make
      > sure they came out
      > correctly)
      > :wall
      >
      > For more reading, you can look at
      >
      > :help nofork
      > :help -s
      > :help read-stdin
      > :help 'hidden'
      > :help argdo
      > :help bufdo
      > :help windo
      > :help wall
      >
      > Just a few ideas. Hope they help,
      >
      > -tim
      >
      >
      >
      >
      >
      >




      __________________________________________
      Yahoo! DSL – Something to write home about.
      Just $16.99/mo. or less.
      dsl.yahoo.com
    • Tim Chase
      ... Not being a perl user, I m afraid I don t know much about doing such a translation. However, much of what a vim script does could be translated into a
      Message 2 of 6 , Jan 1, 2006
        > Thanks a lot for your input. Now only if it can be converted a perl
        > script, then you could use vim to quickly hack scripts and deploy
        > them anywhere even if there is no vim installed :D

        Not being a perl user, I'm afraid I don't know much about doing such a
        translation. However, much of what a vim script does could be
        translated into a scripting language like perl or Python.
        Unfortunately, you'd have to have a fairly exhaustive knowledge of
        vimscript to do such a translation...particularly the functions and Ex
        peculiarities.

        > PS. By the way, do you know of any good vim scripting example sites
        > where I can learn vim scripting? Thanks for your time.

        I'd say the best way to learn is to jump in and try a few simple
        scripts. However, on top of that, you can look at other example scripts
        which are plentiful. There are a number of scripts at Dr. Chip's site:

        http://mysite.verizon.net/astronaut/vim/index.html

        and the vim.org site:

        http://www.vim.org/scripts/index.php

        Once you know one language, learning vimscript is pretty simple--just a
        matter of learning a few syntax differences, and learning the vocabulary
        of available functions.

        For the former (in general), you can check out

        :help eval.txt

        and for the functions, you can simply look up

        :help functions

        for that section in eval.txt

        -tim
      • Rik Herrin
        Thanks a lot Tim. ... __________________________________________ Yahoo! DSL – Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com
        Message 3 of 6 , Jan 1, 2006
          Thanks a lot Tim.

          --- Tim Chase <vim@...> wrote:

          > > Thanks a lot for your input. Now only if it can
          > be converted a perl
          > > script, then you could use vim to quickly hack
          > scripts and deploy
          > > them anywhere even if there is no vim installed :D
          >
          > Not being a perl user, I'm afraid I don't know much
          > about doing such a
          > translation. However, much of what a vim script
          > does could be
          > translated into a scripting language like perl or
          > Python.
          > Unfortunately, you'd have to have a fairly
          > exhaustive knowledge of
          > vimscript to do such a translation...particularly
          > the functions and Ex
          > peculiarities.
          >
          > > PS. By the way, do you know of any good vim
          > scripting example sites
          > > where I can learn vim scripting? Thanks for your
          > time.
          >
          > I'd say the best way to learn is to jump in and try
          > a few simple
          > scripts. However, on top of that, you can look at
          > other example scripts
          > which are plentiful. There are a number of scripts
          > at Dr. Chip's site:
          >
          > http://mysite.verizon.net/astronaut/vim/index.html
          >
          > and the vim.org site:
          >
          > http://www.vim.org/scripts/index.php
          >
          > Once you know one language, learning vimscript is
          > pretty simple--just a
          > matter of learning a few syntax differences, and
          > learning the vocabulary
          > of available functions.
          >
          > For the former (in general), you can check out
          >
          > :help eval.txt
          >
          > and for the functions, you can simply look up
          >
          > :help functions
          >
          > for that section in eval.txt
          >
          > -tim
          >
          >
          >
          >
          >




          __________________________________________
          Yahoo! DSL – Something to write home about.
          Just $16.99/mo. or less.
          dsl.yahoo.com
        • Ted Arnold
          ... Tim, you are really stupid. You admit being ignorant of perl, then you make the stupid claim that vim scripts can be translated into perl. You ignorant
          Message 4 of 6 , Jan 1, 2006
            Tim Chase wrote:
            >> Thanks a lot for your input. Now only if it can be converted a perl
            >> script, then you could use vim to quickly hack scripts and deploy them
            >> anywhere even if there is no vim installed :D
            >
            >
            > Not being a perl user, I'm afraid I don't know much about doing such a
            > translation. However, much of what a vim script does could be
            > translated into a scripting language like perl or Python.
            > Unfortunately, you'd have to have a fairly exhaustive knowledge of
            > vimscript to do such a translation...particularly the functions and Ex
            > peculiarities.

            Tim, you are really stupid. You admit being ignorant of perl, then you make the
            stupid claim that vim scripts can be translated into perl.

            You ignorant weenie, pretending to be an expert.

            Tim, just shut the fuck up. You embarrass weenies everywhere.

            >
            > -tim

            (btw, the weenies at vim-dev deleted me, and pushed me over here to arrass you. shows what they think of you)
          Your message has been successfully submitted and would be delivered to recipients shortly.