Vim 中的 Ruby 代码自动缩进

发布于 2024-11-13 08:58:47 字数 282 浏览 4 评论 0原文

我已将 Ruby 示例复制到 Vim 中,但事实证明这弄乱了缩进。 我尝试让 Vim 应用 Ruby 特定的缩进。为此,我取消了全局 vimrc 文件中以下行的注释:

if has ("autocmd")
  filetype plugin indent on
endif

并在 Vim 中按下了 gg=G。现在它更改了一些缩进,但仍然存在一些错误:

  • 类定义没有缩进。
  • 注释不会缩进并保留在行首。

I have copied a Ruby example into Vim, but it turns out that this messed up the indentation.
I tried to make Vim apply the Ruby specific indentation. To do that I uncommented the following lines in the global vimrc file:

if has ("autocmd")
  filetype plugin indent on
endif

And pressed gg=G in Vim. Now it changes some of the indentation, but it still has some errors:

  • Class definitions don't get indented.
  • Comments don't get indented and remain at the start of the lines.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静若繁花 2024-11-20 08:58:47

在从外部源粘贴之前,使用此命令

:set Paste

然后进入插入模式并粘贴。

Before paste from outer source, use this command

:set paste

then enter to insert mode and paste.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文