V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
ithelloworld
V2EX  ›  程序员

vim编写代码如何把注释快速对齐?

  •  
  •   ithelloworld · 2013 年 3 月 1 日 · 5569 次点击
    这是一个创建于 4710 天前的主题,其中的信息可能已经有所发展或是发生改变。
    例:

    def a_func():
    a = 0 # a的说明
    bc = 1 # b的说明
    ...

    要整理成这样对齐:

    def a_func():
    a = 0 # a的说明
    bc = 1 # b的说明
    ...

    有什么快捷方式能一步办到?
    10 条回复    1970-01-01 08:00:00 +08:00
    ithelloworld
        1
    ithelloworld  
    OP
       2013 年 3 月 1 日
    不支持格式化,上下成一样了:(
    目的是要把多个注释的部分竖着对齐。
    Channing
        2
    Channing  
       2013 年 3 月 1 日   ❤️ 1
    ithelloworld
        3
    ithelloworld  
    OP
       2013 年 3 月 1 日
    谢谢,就要这个:)
    ritksm
        4
    ritksm  
       2013 年 3 月 1 日
    我看了想了30s上下有啥区别。。。。蛋疼。。。。
    ithelloworld
        5
    ithelloworld  
    OP
       2013 年 3 月 1 日
    @ritksm 哈哈,不好意思,你该看下一楼:D
    yueyoum
        6
    yueyoum  
       2013 年 3 月 3 日   ❤️ 1
    因为我也有这样的需求

    所以我自己写了一简单 插件

    https://github.com/yueyoum/vim-alignment

    选中要对齐的行, 然后按下 <leader>[# 回车就行
    aisensiy
        7
    aisensiy  
       2013 年 3 月 3 日
    那这中情况呢

    # asdfsdasdfasdf asd f asd fasdf a sdf
    # asd fas df as df asd fa sdf as df as asdf as df asdf
    # asdfsad asdf as df asd fa sdf as df
    def method
    puts 123
    end

    我想把这样的多行注释的右侧对齐,可以做到吗~最后变成如下

    # asdfsdasdfasdf asd f asd fasdf a sdf
    # asdf as df asdf asd fas df as df asd
    # fa sdf as df as asdfsad asdf as df
    # asd fa sdf as df
    def method
    puts 123
    end
    qiukun
        8
    qiukun  
       2013 年 3 月 3 日
    用 golang
    holy_sin
        9
    holy_sin  
       2013 年 3 月 3 日
    gg=G 可以吗
    ithelloworld
        10
    ithelloworld  
    OP
       2013 年 3 月 4 日
    @holy_sin 不可以
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   977 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 22:02 · PVG 06:02 · LAX 14:02 · JFK 17:02
    ♥ Do have faith in what you're doing.