当我调用代码格式化程序时,如何避免扩展折叠区域? [英] How do I avoid expanding folded regions when I invoke the code formatter?

查看:151
本文介绍了当我调用代码格式化程序时,如何避免扩展折叠区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如您所知,Delphi 2010内置了代码格式。但是,格式化展开所有折叠的代码块。任何想法如何解决?这个功能对我来说特别烦人,当我找不到任何提到这个问题的时候,我真的很惊讶。我试过的:




  • 搜索替代方案,例如GExperts有代码格式化程序插件,但它也展开代码块。

  • 尝试为GExperts写入一个宏:Ctrl + D(格式代码) - >各种代码折叠/展开快捷方式,但无法使其尊重所有折叠/展开的块结构。

  • 编写CnWizards脚本,但找不到代码折叠示例。



我会非常感谢任何想法/提示。

解决方案

一种解决方法是不要一次格式化整个文件,而是选择一部分,并格式化。



只要不选择区域,所有区域的展开状态仍然保持不变。



一次格式化整个文件通常不是一个好主意,因为格式化程序不理解它在做什么。我总是检查它所做的所有更改,当在可见区域之外没有更改时,这更容易。


As you know, Delphi 2010 has built-in code formatting. However, formatting unfolds all folded code blocks. Any ideas how to fix it? This "feature" is particularly annoying for me and I was really astonished when I couldn't find any mention of this problem. What I've tried:

  • Searching for alternative, e.g., GExperts have code formatter plugin, but it also unfolds code blocks.
  • Tried to write a macro for GExperts: Ctrl+D(format code) -> various code folding/unfolding shortcuts, but couldn't manage to make it respect all folded/unfolded block structures.
  • Write a CnWizards script, but could't find a code folding example.

I would be really grateful for any idea/hint.

解决方案

One way to work around it is to not format the entire file at once, but to select a portion, and format that.

As long as you don't select a region, the expand-state of all regions remains untouched.

Formatting an entire file at once is usually not really a good idea anyway, because the formatter doesn't "understand" what it's doing. I always inspect all changes that it makes, and that's easier when there are no changes outside of the area that's visible.

这篇关于当我调用代码格式化程序时,如何避免扩展折叠区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆