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

Re: Is it possible to pass arguments to gvim through a file

Expand Messages
  • Tim Chase
    ... IIUC, you want to put commands in arguments.txt, and then, upon opening c:log.txt, you want to execute the commands in arguments.txt I presume
    Message 1 of 5 , Nov 1, 2007
    • 0 Attachment
      > I have a batch file which open some logfile and search for the first error.
      > It contains something like:
      > gvim.exe +/Error "C:\log.txt"
      >
      > Is it possible to give a file argument with bunch of arguments to gvim?
      > For example
      > gvim.exe +arguments.txt "C:log.txt"
      >
      > In this arguments.txt you then tell to do several actions
      > - delete all lines starting with Info
      > - delete the warning Couldn't .....
      > - search for the first error

      IIUC, you want to put commands in arguments.txt, and then, upon
      opening c:log.txt, you want to execute the commands in arguments.txt

      I presume arguments.txt looks something like

      g/^Info/d
      g/Couldn't/d
      setlocal wrapscan
      $/Error

      A couple ideas occur to me:

      You might be able to use something like

      vim -c "so arguments.txt" c:log.txt

      If it's a one-off, you might try something like

      vim -c"g/^Info/d" -c"g/Couldn't/d" +/Error/ c:log.txt

      If it's something you do regularly, you could use an autocmd such as

      :autocmd BufRead log.txt so /path/to/arguments.txt

      which might do the trick. (untested)

      Or, you can pre-treat the file with something like
      sed/grep/findstr before loading:

      vim +/Error/ <(sed -e "/^Info/d" -e "/Couldn't/d" c:log.txt)
      vim +/Error/ <(grep -v '^Info' c:log.txt | grep -v "Couldn't")

      which works in bash. If your shell (it sounds like you're on
      Win32, as you reference "batch files" rather than "shell
      scripts"). In another shell, you might be able to use an
      intermediate file:

      sed -e "/^Info/d" -e "/Couldn't/d" c:log.txt > temp.txt
      vi temp.txt

      On Win32, the findstr command is something akin to a wimpy grep.

      Just a couple ideas you might want to try,

      -tim






      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • A.Politz
      ... gvim.exe -S arguments.vim C:log.txt -ap -- Ich hab geträumt, der Krieg wär vorbei. --~--~---------~--~----~------------~-------~--~----~ You received
      Message 2 of 5 , Nov 1, 2007
      • 0 Attachment
        Eric Leenman wrote:

        >Hi,
        >
        >I have a batch file which open some logfile and search for the first error.
        >It contains something like:
        >gvim.exe +/Error "C:\log.txt"
        >
        >Is it possible to give a file argument with bunch of arguments to gvim?
        >For example
        >gvim.exe +arguments.txt "C:log.txt"
        >
        >In this arguments.txt you then tell to do several actions
        >- delete all lines starting with Info
        >- delete the warning Couldn't .....
        >- search for the first error
        >
        >Rgds,
        >Eric
        >
        >>
        >
        >

        gvim.exe -S arguments.vim "C:log.txt"

        -ap


        --
        Ich hab geträumt, der Krieg wär vorbei.


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Ben Schmidt
        ... Phew! Thanks, ap. I wondered when -S would show up! Still not exactly what the poster asked for, of course, but nicer than a custom vimrc! Ben. Send
        Message 3 of 5 , Nov 1, 2007
        • 0 Attachment
          > gvim.exe -S arguments.vim "C:log.txt"

          Phew! Thanks, ap.

          I wondered when -S would show up! Still not exactly what the poster asked for, of
          course, but nicer than a custom vimrc!

          Ben.





          Send instant messages to your online friends http://au.messenger.yahoo.com


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        Your message has been successfully submitted and would be delivered to recipients shortly.