自动折叠括号的文本编辑器?
我正在调试一些大而混乱的 SQL 程序,它们往往有很多严重嵌套的括号:
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
我正在寻找一个编辑器,可以自动标记并可选择折叠/折叠每个括号设置以方便阅读,例如
SELECT * FROM ... AS X1
SELECT * FROM (SELECT F1,F2 FROM TABLE1 AS X LEFT JOIN ... AS B ON X.F1=B.F9) AS X1
我可以在 Visual Studio 中通过重复按 ctrl-shift-] 选择一组,然后按 ctrl-mh 折叠它来执行此操作。但其中一些内容长达数百行,如果我有一个可以自动标记整个文档的编辑器,那就太好了。
有什么建议吗?
I have some 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不认为它会完成你的折叠,但如果你使用 SQL Server,我强烈推荐 SQL 提示符,其中包含重新格式化 SQL 的命令。我发现这在调试/理解巨大且笨重的存储过程时有很大的帮助。
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.
我需要做类似的事情。我发布了征求意见和建议的请求(你可以说是 RFC)。它的链接在这里: Stack溢出。我很惊讶它不是大多数编辑器的标准功能。我想问题是从字符流中解析分隔的文本块比看起来更难。也许 XML 和 CSS 将使将来做一些事情变得更容易。
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.
请参阅 emacs 的 HideShow 模式,它正是您在 lisp 中想要的功能 -模式。
See HideShow mode for emacs, which does exactly what you want in lisp-mode.
编辑:没关系,它不起作用。
)
没有被视为接近。留下答案,以免其他人浪费时间尝试。如果您愿意拆分行,以便一行上只有一个左括号或右括号,您可以使用 Notepad++ 中的用户定义语言,并将
(
和)
分别打开和关闭文件夹。您还可以定义 SQL 关键字和注释分隔符,以便它们带有颜色。 Notepad++ 当然内置了 SQL,但是内置的定义不会折叠在括号上。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.