Vim indentation for c++ templates?

前端 未结 2 1720
青春惊慌失措
青春惊慌失措 2021-02-04 18:48

Does anyone have or know about vim plugin/macro/function that indents nicely c++ templates?

When I highlight template definition in vim .hpp/.h file and indent it with \

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 19:04

    You can use the identexpr option to specify indent by evaluating an expression (i.e. writing a vim script function). This function should accept a string -- the line -- and return the number of spaces to indent. This gives you the flexibility to return an indent level for this template condition, or fall-back to autoindent, smartindent or cindent in normal, C-like situations.

    Here is an example that was created to handle the signals and slots extension of Qt. It demonstrates fall-back to the cindent function.

提交回复
热议问题