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

Re: Eval

Expand Messages
  • Benji Fisher
    ... It should be possible to do it in a vim script. This probably won t work, but I think it illustrates all the right pieces: let flist = glob( *.ads ) let
    Message 1 of 4 , Nov 29, 2001
      Preben Randhol wrote:
      >
      > I have a small script that reads the filenames of some selected files in
      > a directory and outputs some commands for vim. I'm not familiar with vim
      > scripting so I just hacked something fast in bash/awk:
      >
      > --myscript.sh-------
      > #!/bin/sh
      >
      > ADS="*.ads"
      > ADB="*.adb"
      >
      > for file in $ADS; do
      > echo $file | awk '{ split($1,name,"."); print ":menu Project.ads." name[1] " :e "$1"<CR>"}'
      > done
      > for file in $ADB; do
      > echo $file | awk '{ split($1,name,"."); print ":menu Project.adb." name[1] " :e "$1"<CR>"}'
      > done
      > -------
      >
      > The output of the script is then :
      >
      > :menu Project.ads.window-callbacks :e window-callbacks.ads<CR>
      > :menu Project.ads.wordgroups :e wordgroups.ads<CR>
      > :menu Project.adb.double_linked_list :e double_linked_list.adb<CR>
      > :menu Project.adb.examine :e examine.adb<CR>
      >
      > etc...
      >
      > I tried to simply do:
      >
      > :!myscript.sh
      >
      > but that only lists the output of the script. How can I get vim to
      > interpret the output. Of course if somebody knows how I can do this in
      > vim script it would be even better :-)

      It should be possible to do it in a vim script. This probably won't
      work, but I think it illustrates all the right pieces:

      let flist = glob("*.ads")
      let flist=substitute(flist, '\(\f\+\)\.ads',
      \ 'menu Project.vim.\1 :e \1.ads<CR>', 'g')
      execute flist

      :help glob()
      :help substitute()
      :help /\1
      :help :execute

      HTH --Benji Fisher
      let flist = substitute(flist, '\
    Your message has been successfully submitted and would be delivered to recipients shortly.