我怎么能自动套用格式的VIM /缩进C code吗? [英] How can I autoformat/indent C code in vim?

查看:108
本文介绍了我怎么能自动套用格式的VIM /缩进C code吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从另一个文件拷贝code,格式化被搞砸了,是这样的:

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

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

如何能我自动套用格式到Vim code?

How can I autoformat this code in vim?

推荐答案

试试下面的快捷键:

gg=G

说明: GG 转到文件的顶部, = 是修复压痕和命令< codeG 告诉它要执行的操作的文件的末尾。

Explanation: gg goes to the top of the file, = is a command to fix the indentation and G tells it to perform the operation to the end of the file.

这篇关于我怎么能自动套用格式的VIM /缩进C code吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆