【问题标题】:After uncommenting a block of code in NERD_commenter, it's improperly indented在 NERD_commenter 中取消注释一段代码后,它的缩进不正确
【发布时间】:2012-08-11 20:44:47
【问题描述】:

我有一些python代码:

     _name = "football.player"
     _description = "Football Player"
     def age_calc(self, cr, uid, ids, fields, arg, context=None):

当我在 NERD_commenter 中按 ,cc 进行评论时,它看起来像这样:

     _name = "football.player"
#     _description = "Football Player"
#     def age_calc(self, cr, uid, ids, fields, arg, context=None):

但取消注释后,使用,cu 看起来像这样:

     _name = "football.player"
    _description = "Football Player"
    def age_calc(self, cr, uid, ids, fields, arg, context=None):

为什么这个未注释的块看起来移动了 1 个空格,而不是在其原始位置?以及如何解决?

【问题讨论】:

  • 因为注释会在开头插入一个哈希。没有什么可修复的。
  • @CatPlusPlus:我认为问题在于“NERD_commenter”在取消注释后似乎做错了。
  • 2 Cat Plus Plus。我不明白你。你的意思是什么“哈希”?我想知道为什么当我评论时,它将文本替换为 1 个空格,但是当我取消注释时,NERD 将其替换为 2 个空格
  • 我无法通过 nerdcommenter 重现此行为

标签: vim plugins indentation


【解决方案1】:

这可能是因为您使用了 5 个空格。您的 tabstop / shiftwidth 设置为多少?它可能会尝试将其缩进到一个合乎逻辑的标准 (4) 个空格,而不是一个疯狂的 (5) 个空格。

如果你真的想为一个制表符使用 5 个空格(你不这样做),你可以使用 :set shiftwidth=5:set tabstop=5:set et 如果你没有它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-02
    • 2011-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多