- 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>.
推薦閱讀
- PHP動態網站程序設計
- OpenDaylight Cookbook
- 薛定宇教授大講堂(卷Ⅳ):MATLAB最優化計算
- Cassandra Data Modeling and Analysis
- Python數據分析(第2版)
- Learning OpenCV 3 Computer Vision with Python(Second Edition)
- 計算機應用基礎實踐教程
- 編程可以很簡單
- C++ System Programming Cookbook
- PHP 8從入門到精通(視頻教學版)
- Mastering Machine Learning with R
- 開源網絡地圖可視化:基于Leaflet的在線地圖開發
- Mastering Vim
- jQuery基礎教程(第4版)
- Learning jqPlot