Notepad++ and SQL... wtf

Soldato
Joined
20 Oct 2002
Posts
3,467
Location
London, 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:
Associate
Joined
5 Jan 2003
Posts
752
Location
Norfolk
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:

Pho

Pho

Soldato
Joined
18 Oct 2002
Posts
9,324
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.
 
Soldato
OP
Joined
20 Oct 2002
Posts
3,467
Location
London, UK
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.
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:
/* comment here */
/* comment here */

code here

/* comment here */
instead of:


/* comment here */
/* comment here */


code here


/* comment here */
Where yellow represents comments
 
Last edited:

Pho

Pho

Soldato
Joined
18 Oct 2002
Posts
9,324
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.
 
Soldato
OP
Joined
20 Oct 2002
Posts
3,467
Location
London, UK
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.

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
 
Soldato
OP
Joined
20 Oct 2002
Posts
3,467
Location
London, UK
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.
I'll check it out, thanks, and I use Teradata SQL btw :)

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

looks the same and I can't see notepad++ kicking up a fuss over it.
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.
 
Soldato
OP
Joined
20 Oct 2002
Posts
3,467
Location
London, 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:
Back
Top Bottom