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

RE: Regular Expression Question

Expand Messages
  • Gene Kwiecinski
    I hope you don t mind a non-vim solution, but I used to run into this problem all the time when I wanted to match tabbing for debugging/status messages that
    Message 1 of 13 , Jan 26, 2007
    • 0 Attachment
      I hope you don't mind a non-vim solution, but I used to run into this
      problem all the time when I wanted to match tabbing for debugging/status
      messages that would come to the screen. I just got so sick and tired of
      hopping through the code to add a tab here, remove a tab there, etc.,
      that I'd just bunch together all the string constants in one place, at
      the top. Eg:

      const char
      *msg_help[] = {
      "usage: %s [-options] [infile [outfile]]\n",
      "\toptions:\n",
      "\t\t-h\thelp\n",
      "\t\t-l\tlong (detailed) output\n",
      (const char *)0
      };

      const char
      dbg_rdferr[] = "%s: cannot open \"%s\" for reading\n",
      dbg_wrferr[] = "%s: cannot open \"%s\" for writing\n",
      ...

      and have everything even visually aligned in one place. Would also let
      me "reuse" the same strings as needed (eg, "%d" as an input to sscanf(),
      "%02X" as a 2-digit output to fprintf(), etc.) without having to wonder
      if I mistyped something that would only break when some rarely-used
      piece of code would run.

      Then, once all your strings are in a row, just look for

      \n"[,;]$

      and every string with the necessary newline at the end should be
      highlighted. Any string that's *not* highlighted (ie, would be missing
      the trailing newline) would, umm, would *not*, stand out.

      Granted, that's not a vimmy solution to your problem, but it's a little
      habit I got myself into, and for me at least, it made life a little
      easier.

      Any help?
    Your message has been successfully submitted and would be delivered to recipients shortly.