• 请不要在回答技术问题时复制粘贴 AI 生成的内容
ithelloworld
V2EX  ›  程序员

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

  •  
  •   ithelloworld · Mar 1, 2013 · 5771 views
    This topic created in 4839 days ago, the information mentioned may be changed or developed.
    例:

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

    要整理成这样对齐:

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

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

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

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

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

    # 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  
       Mar 3, 2013
    用 golang
    holy_sin
        9
    holy_sin  
       Mar 3, 2013
    gg=G 可以吗
    ithelloworld
        10
    ithelloworld  
    OP
       Mar 4, 2013
    @holy_sin 不可以
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5827 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 69ms · UTC 03:41 · PVG 11:41 · LAX 20:41 · JFK 23:41
    ♥ Do have faith in what you're doing.