VIM has a ggG formatting code command. How can I customize this custom rule? VIM has
gg=GFormat Code commands.
How can I customize this custom rule?
Reply content:
VIM hasgg=GFormat Code commands.
How can I customize this custom rule?
This problem is a little too big. It is not realistic to explain it clearly. Some basic concepts are provided for reference:
First, for what you want to know,gg=GOnly=Only help=Role Determination
.
=The working mechanism of is as follows:
- First, it looks for the user-specified external indent tool. If yes, it is used to indent the target range. Use
The option for specifying the external indent tool isequalprgYou should take a look at its documentation.
Vimcasts has a video to demonstrate an instance in which Drew Neil demonstrates how to use Par
After formatting plain text, another example demonstrates how to format HTML with pandoc. In both examples
YesformatprgAndformatexprParameter (correspondinggqInstead=Format
But the principle and usage are the same.
- However
equalprgThe default value is null. If you do not have a proper external indent tool, Vim will use the built-in
Indent FunctionC-indentingAnd'Lisp'You 'd better take a look at these two documents. In addition, if you use
If the built-in indentation function is not included in Vim compilation, the built-inindent()Function to do jobs --
This is the final method, and the document is worth reading (you can use it when writing your own indent script ).
- Another important setting is:
indentexpr. As mentioned earlier, ifequalprgNot set,=Yes
C-indentingAnd'Lisp'But ifindentexprThen
Replace the first two and all other built-in indent-expressions ).
If youequalprgAndindentexprIt's easy: the former only affects=Effect
The latter determines all indent functions. For example, we can use=In addition to indent adjustmentINPUTModule
Vim will automatically adjust the indentation. SoindentexprThe impact scope is wider, which is also defined by the user.
The main method of indentation rules (there is alsoindentkeysThese two documents are also very useful ).