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

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

  •  
  •   ithelloworld · Mar 1, 2013 · 6186 views
    This topic created in 4995 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
    ithelloworld
    OP
    Mar 1, 2013
    1
    不支持格式化,上下成一样了:(
    目的是要把多个注释的部分竖着对齐。
    Channing
    Channing
    Mar 1, 2013❤️1
    2
    ithelloworld
    ithelloworld
    OP
    Mar 1, 2013
    3
    谢谢,就要这个:)
    ritksm
    ritksm
    Mar 1, 2013
    4
    我看了想了30s上下有啥区别。。。。蛋疼。。。。
    ithelloworld
    ithelloworld
    OP
    Mar 1, 2013
    5
    @ritksm 哈哈,不好意思,你该看下一楼:D
    yueyoum
    yueyoum
    Mar 3, 2013❤️1
    6
    因为我也有这样的需求

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

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

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

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