官术网_书友最值得收藏!

  • Mastering Vim
  • Ruslan Osipov
  • 229字
  • 2021-06-10 18:51:29

Types of folds

Vim is somewhat intelligent when it comes to folding code, and supports multiple ways to fold code. The folding method is guarded by a foldmethod option in your .vimrc file. Supported fold methods are as follows:

  • manual allows you to manually define folds. This becomes unrealistic when working with any substantial body of text.
  • indent supports indentation-based folding, which is perfect for languages and code bases where indentation matters (regardless of the language you're working with, a standardized code base is likely to have some consistent indentation, making indent a quick and easy way to fold away bits you don't care for).
  • expr allows for a regular-expression based folding. This is an extremely powerful tool if you have complex custom rules you'd like to use for defining folds.
  • marker uses special markup in the text, such as {{{ and }}}. This is useful for managing long .vimrc files, but has little use outside of the Vim world since it requires modifying file content.
  • syntax provides syntax-aware folds. However, not every language is supported out of the box (Python isn't).
  • diff is automatically used when Vim operates in a diff mode, displaying the difference between two files (see Vimdiff in Chapter 5, Build, Test, and Execute).
Reminder: you can set an option in your .vimrc file by adding the following line: set foldmethod=<method>.
主站蜘蛛池模板: 鞍山市| 改则县| 连山| 丘北县| 镶黄旗| 建昌县| 武鸣县| 化州市| 屏东县| 鄂托克旗| 柏乡县| 沁水县| 东乌珠穆沁旗| 赤壁市| 光山县| 大丰市| 东丽区| 称多县| 监利县| 泸西县| 德令哈市| 鄂伦春自治旗| 西乌珠穆沁旗| 湟源县| 桂平市| 乌恰县| 江陵县| 金塔县| 朔州市| 盖州市| 普洱| 万全县| 丹江口市| 赤壁市| 龙川县| 宿松县| 苏尼特右旗| 孝昌县| 博野县| 建水县| 龙门县|