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

Using gf with a modified filename

Expand Messages
  • Ondrejko, David
    Vimmers, I have an unusual problem. I m using Vim 5.8 on a Windows NT machine to edit COBOL program files downloaded from a DOS/VSE mainframe platform. The
    Message 1 of 4 , Jun 1, 2001
    • 0 Attachment
      Using gf with a modified filename

      Vimmers,

      I have an unusual problem.  I'm using Vim 5.8 on a Windows NT machine to edit COBOL program files downloaded from a DOS/VSE mainframe platform.

      The files on the mainframe don't have extensions.  However, in order to get the copybooks (i.e., the COBOL version of #include files) to use syntax highlighting, I usually download them and add an extension of .cpy to them, and add .cpy to the list in the filetypes.

      So I may end up with a copybook that on the mainframe is known as COPYBK1 and on My machine it is called COPYBK1.CPY.  This works out OK *except* that I can't use a command like gf to jump to the file, since the COBOL program has the statement "COPY COPYBK1" in it.

      So I would like to know how to make gf (and similar commands, if possible) automagically add a ".cpy" extension to the filename whenever I use it, and still search the "path" variable.

      Is that possible?

      -- Davyd

    • Preben Guldberg
      ... Suppose you keep these file in one place, you might want to use an autocommand like ... or some such. Peppe -- Before you criticize someone, walk Preben
      Message 2 of 4 , Jun 1, 2001
      • 0 Attachment
        Thus wrote Ondrejko, David (david.ondrejko@...) on [010601]:

        > The files on the mainframe don't have extensions. However, in order to get
        > the copybooks (i.e., the COBOL version of #include files) to use syntax
        > highlighting, I usually download them and add an extension of .cpy to them,
        > and add .cpy to the list in the filetypes.

        Suppose you keep these file in one place, you might want to use an
        autocommand like

        :au BufRead,BufNewFile some/path/* set ft=cobol

        or some such.

        Peppe
        --
        "Before you criticize someone, walk
        Preben "Peppe" Guldberg __/-\__ a mile in his shoes. That way, if
        c928400@... (o o) he gets angry, he'll be a mile away
        ----------------------oOOo (_) oOOo-- - and barefoot." --Sarah Jackson
      • Ondrejko, David
        ... Interesting suggestion, but I can t seem to get it to work ... and it still wouldn t let Me use gf to go from the program to the copybook with an extension
        Message 3 of 4 , Jun 1, 2001
        • 0 Attachment
          RE: Using gf with a modified filename

          >> The files on the mainframe don't have extensions.
          >> However, in order to get the copybooks (i.e., the
          >> COBOL version of #include files) to use syntax
          >> highlighting, I usually download them and add an
          >> extension of .cpy to them, and add .cpy to the list
          >> in the filetypes.
          >
          > Suppose you keep these file in one place, you might
          > want to use an autocommand like
          >
          >    :au BufRead,BufNewFile some/path/*  set ft=cobol
          >
          > or some such.

          Interesting suggestion, but I can't seem to get it to work ... and it still wouldn't let Me use gf to go from the program to the copybook with an extension of .cpy.

          What I *can* do is just remove the extensions from the files (losing the ability to immediately pick them out of an Explorer or directory listing as copybooks, have specialized icons in Explorer, etc.) and add *. to the list of COBOL types in the myfiletypes list.  Since in the program, the include statement is "COPY COPYBK." (with a period at the end) I can jump to it from within a program and the highlighting is (usually) OK. 

          However, if I start editing it on its own, or use ":bro e" to bring it in, the syntax highlighting is lost.  I'll note also that My current path is set to:

          path=.,,C:\Ftp\Copybooks

          Using the settings noted above (removing the extension and adding *. to the COBOL list), if it is in the C:\Ftp\Copybooks directory the highlighting is automatically turned on.  That's (part of) what I want.  HOWEVER, if it is in the same directory as the program I want to jump from, the file comes up without syntax highlighting on.  Am I doing something wrong in the path statement?  (I want it to look in the current directory BEFORE it looks in the copybooks directory.)

          Thanks for all of your help!

          -- Davyd

        • Douglas L Potts
          ... [--- snip ---] ... As is almost anything else with VIM, ... of course. Depending on your Vim flavor (6.0 or 5.8 and below): vim 6.0 - has suffixesadd, to
          Message 4 of 4 , Jun 1, 2001
          • 0 Attachment
            On Fri, Jun 01, 2001 at 10:18:19AM -0400 Ondrejko, David wrote:
            >
            > Vimmers,
            [--- snip ---]
            > So I would like to know how to make gf (and similar commands, if possible)
            > automagically add a ".cpy" extension to the filename whenever I use it, and
            > still search the "path" variable.
            >
            > Is that possible?
            As is almost anything else with VIM, ... of course.

            Depending on your Vim flavor (6.0 or 5.8 and below):
            vim 6.0 - has suffixesadd, to add your .cpy to the end.

            vim 5.8 to 5.4 (need the sfind comto 5.4):
            there is a function that Stefan Roemer posted back in June 99 called
            FindFile that you add your .cpy extensions to the 'ext' variable in the
            function. And then gf and the like get mapped to call this function
            with the correct parameters.

            You should be able to drudge this up on egroups (now yahoo groups I
            think), or if you need it I can email it, or it is on my vim macros page
            on my web page (see url below).

            HTH,
            -Doug

            --
            *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
            Douglas L. Potts Url: http://www.bigfoot.com/~pottsdl
            "Debating unix flavors in the context of anything Microsoft is like talking
            about which ice cream flavor tastes least like sawdust with turpentine sauce."
            --(void) in alt.sysadmin.recovery
            *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
          Your message has been successfully submitted and would be delivered to recipients shortly.