How can I autoformat/indent C code in vim?

后端 未结 9 2452
青春惊慌失措
青春惊慌失措 2020-11-29 14:20

When I copy code from another file, the formatting is messed up, like this:

fun()
{
for(...)
{
for(...)
{
if(...)
{
}
}
}
}

How can I autof

9条回答
  •  一整个雨季
    2020-11-29 14:55

    The plugin vim-autoformat lets you format your buffer (or buffer selections) with a single command: https://github.com/Chiel92/vim-autoformat. It uses external format programs for that, with a fallback to vim's indentation functionality.

提交回复
热议问题