开发者

A text editor that auto-folds parentheses?

开发者 https://www.devze.com 2022-12-10 05:18 出处:网络
I have s开发者_Go百科ome big messy SQL procedures that I\'m debugging, and they tend to have a lot of heavily nested parentheses:

I have s开发者_Go百科ome big messy SQL procedures that I'm debugging, and they tend to have a lot of heavily nested parentheses:

SELECT * FROM (SELECT F1,F2 FROM TABLE1 AS X LEFT JOIN 
(SELECT F9,F8 FROM (SELECT F13,F14 FROM TABLE4) AS J INNER JOIN TABLE3 ON...) AS B 
ON X.F1=B.F9) AS X1

I'm looking for an editor that can automatically mark and optionally collapse/fold each parentheses set to ease reading, e.g.

SELECT * FROM ... AS X1

SELECT * FROM (SELECT F1,F2 FROM TABLE1 AS X LEFT JOIN ... AS B ON X.F1=B.F9) AS X1

I can do this in Visual Studio by repeatedly hitting ctrl-shift-] to select a set, and then ctrl-mh to collapse it. But some of these things are hundreds of lines long and it would be nice if I had an editor that could mark up the whole document automatically.

Any suggestions?


I don't think it'll do your folding, but if you're using SQL Server I'd highly recommend SQL Prompt which includes a command to reformat SQL. I've found this to be a massive help when debugging/understanding huge and unwieldy stored procedures.


I have a need to do a similar thing. I posted a request for comments and suggests (an RFC you could say). The link to it is here: Stack Overflow. I'm surprised its not a standard feature in most editors.. I guess the issue is that it's harder than it looks to parse delimited blocks of text out of a stream of characters. Maybe XML and CSS will make it easier to do thins type of thing in the future.


See HideShow mode for emacs, which does exactly what you want in lisp-mode.


Edit: Nevermind, it doesn't work. ) isn't being treated as close. Leaving the answer so nobody else wastes their time trying it.

If you're willing to split the lines so there's only one open or close parenthesis on a line, you can use the User Define Language in Notepad++ and make ( and )the folder open and close, respectively. You can also define the SQL keywords and comment delimiters so they get colored. Notepad++ has SQL built in of course, but the built in definition doesn't fold on parentheses.

0

精彩评论

暂无评论...
验证码 换一张
取 消