代码折叠

Posted xin04

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了代码折叠相关的知识,希望对你有一定的参考价值。

原文地址

Folding in code

三、代码折叠

Folding in code is quite different in UDL 2.1. Instead of two keyword sets (open and close), now we have three keyword sets (open, middle and close). Also, there are two Folding in code groups: one for forward (style1) and one for backward (style2) search.

Example 1

This is a typical C++ folding definition.
Curly braces represent folding points in the code and preprocessor is also supported (for this demo not all statements were defined)

技术图片

There are two important things here.
As you can see both Folding 1 and Folding 2 create folding points, but they work differently.

  • Folding 1 (the curly braces) is detected using forward search. It means these keywords can be “glued” to some other keyword. In this case opening curly brace stands next to closing round brace, and in line 12 around word “int”
  • Folding 2 (preprocessor stuff) works when surrounded by white space, but not when glued to word “UNICODE”, as demonstrated in line 14

技术图片

Note: forward and backward search concept is explained in more detail in Introduction page.
You should read that part if you haven’t already.

Example 2

UDL 2.1 will automatically create middle folding point if open folding point is followed by a close folding point on the same line.

技术图片

Example 3

Use of multi-part keywords is supported in Folder in code 2, as you can see in this example.

技术图片

以上是关于代码折叠的主要内容,如果未能解决你的问题,请参考以下文章

Vim代码折叠的indent模式

VScode怎么在代码折叠后,插入新的内容

vscode 如何快速把折叠的代码块给注释了?

代码折叠

折叠/展开代码块

macvim无法折叠代码“ E490:找不到折叠”