1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Notepad++ and SQL... wtf

Discussion in 'HTML, Graphics & Programming' started by Heofz, 20 Oct 2009.

  1. Heofz

    Mobster

    Joined: 20 Oct 2002

    Posts: 3,451

    Location: Basingstoke, UK

    Hey everyone,

    For those of you who use notepad++, can you please do me a favour?

    At work I go through a fair bit of SQL code and my colleagues tend to use this syntax for comments:

    /*********** comment *********/

    When set to SQL syntax highlighting, what is really starting to **** me off is that I'm trying to get these to show up in notepad++ as comments, but for some reason they are treated as normal text.

    If I have this, then it works fine:

    /* comment */

    It is only when multiple asterisks are involved it messes up. This does not happen if I set the syntax language to anything else that can use /* */ for commenting, e.g. PHP, Verilog, etc. I have spent ages scouring the web, Google, and all the notepad++ XML files looking to find what defines the behaviour of comments, and why this is happening, but to no avail.

    I wouldn't be so annoyed if language definitions in Notepad++ were documented better :mad:

    So yeah, anyone who's encountered this and may be able to point me towards a solution will be awarded many internets :)

    P.S. The Style Configurator GUI in notepad++ is utterly useless for this, as it only lets me change the colours & font etc, not the low level intricacies of what defines a comment and what doesn't. :(
     
    Last edited: 20 Oct 2009
  2. ChrisB

    Hitman

    Joined: 5 Jan 2003

    Posts: 747

    Location: Liverpool/Norwich(NRP)

    Lang def file:
    C:\Program Files\Notepad++\langs.model.xml

    It doesn't do any pattern matching, so /* is not the same as /**

    Bah, just re-read your post. Ignore me, I'm an idiot.
     
    Last edited: 20 Oct 2009
  3. Pho

    Sgarrista

    Joined: 18 Oct 2002

    Posts: 9,133

    Location: Derbyshire

    It's a pain, but you could go to view > user define dialog and create your own language. Tick 'Treat keywords as symbols' above 'comment open' to get your /*** comments working.
     
  4. Heofz

    Mobster

    Joined: 20 Oct 2002

    Posts: 3,451

    Location: Basingstoke, UK

    Ah cool, thanks :)

    Is there any way I can configure the existing SQL language definition to have this option on also? In other words, if you happen to know where in the XML data it is kept?

    edit: damn, just tried it, and for some reason it comments out the entirety of my code :(

    for example:
    instead of:


    Where yellow represents comments
     
    Last edited: 20 Oct 2009
  5. Pho

    Sgarrista

    Joined: 18 Oct 2002

    Posts: 9,133

    Location: Derbyshire

    Damn, I'm sure it worked for me. I couldn't figure out how to copy the existing SQL settings though sorry.

    Can't you just tell your devs to use -- instead? That works fine :p.
     
  6. Heofz

    Mobster

    Joined: 20 Oct 2002

    Posts: 3,451

    Location: Basingstoke, UK

    Heh, the problem is that I'm the new guy, and they are used to just using plain old notepad with no syntax highlighting at all. Yuck :o
     
  7. Pho

    Sgarrista

    Joined: 18 Oct 2002

    Posts: 9,133

    Location: Derbyshire

    Ah, I'm not too sure then :o.

    You could always get Management Studio Express which is great for this kind of thing, assuming you're using MSSQL mainly.
     
  8. AHarvey

    Capodecina

    Joined: 6 Mar 2008

    Posts: 10,004

    Location: Stoke area

    can't you just use /* ********* comment ******** */

    looks the same and I can't see notepad++ kicking up a fuss over it.
     
  9. Heofz

    Mobster

    Joined: 20 Oct 2002

    Posts: 3,451

    Location: Basingstoke, UK

    I'll check it out, thanks, and I use Teradata SQL btw :)

    Thanks for the suggestion but that kind of defeats the object in having it look right as soon as I see it. I mean it's not a huge deal or anything, I'm just a bit confused as to why comment syntax semantics are inconsistent in Notepad++ when there is no option to control this.
     
  10. HungryHippos

    Sgarrista

    Joined: 25 Mar 2004

    Posts: 8,581

    Location: Fareham

    we always use -- for comments, what does notepadd ++ do with this?

    i.e:

    -- Comment Here
     
  11. Moredhel

    Mobster

    Joined: 11 May 2004

    Posts: 4,786

    Location: Gloucester

    /* */ isn't the standard way of doing comments in SQL, -- comment is.
     
  12. NickK

    Capodecina

    Joined: 13 Jan 2003

    Posts: 18,902

    Yup was about to say! Also "REM" from memory.
     
  13. Heofz

    Mobster

    Joined: 20 Oct 2002

    Posts: 3,451

    Location: Basingstoke, UK

    Oh yeah don't get me wrong, "--" works fine for comments, and that is how I do it personall, and any time I actually modify any code, I'll take ownership of it, and go through the comments and change it using notepad++'s RegEx find & replace:

    find:
    Code:
    /[\*]+([0..9A..Za..z ]*)[\*]+/
    replace with:
    Code:
    -- /1
    This changes "/* abcd */" or "/***** abcd ***/" into "-- abcd"

    It is just sometimes I have to go through my colleagues' SQL code, and it is nice being able to block out comments in my mind without the minor annoyance of seeing comments randomly highlighted as normal text. :p
     
    Last edited: 21 Oct 2009