V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ithelloworld
V2EX  ›  程序员

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

  •  
  •   ithelloworld · 2013-03-01 16:58:03 +08:00 · 4919 次点击
    这是一个创建于 4074 天前的主题,其中的信息可能已经有所发展或是发生改变。
    例:

    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-03-01 16:59:25 +08:00
    不支持格式化,上下成一样了:(
    目的是要把多个注释的部分竖着对齐。
    Channing
        2
    Channing  
       2013-03-01 17:01:52 +08:00   ❤️ 1
    ithelloworld
        3
    ithelloworld  
    OP
       2013-03-01 17:19:14 +08:00
    谢谢,就要这个:)
    ritksm
        4
    ritksm  
       2013-03-01 17:45:54 +08:00
    我看了想了30s上下有啥区别。。。。蛋疼。。。。
    ithelloworld
        5
    ithelloworld  
    OP
       2013-03-01 21:16:54 +08:00
    @ritksm 哈哈,不好意思,你该看下一楼:D
    yueyoum
        6
    yueyoum  
       2013-03-03 00:46:14 +08:00   ❤️ 1
    因为我也有这样的需求

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

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

    选中要对齐的行, 然后按下 <leader>[# 回车就行
    aisensiy
        7
    aisensiy  
       2013-03-03 01:41:55 +08:00
    那这中情况呢

    # 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-03-03 08:52:59 +08:00
    用 golang
    holy_sin
        9
    holy_sin  
       2013-03-03 23:37:25 +08:00
    gg=G 可以吗
    ithelloworld
        10
    ithelloworld  
    OP
       2013-03-04 09:32:10 +08:00
    @holy_sin 不可以
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   937 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 22:04 · PVG 06:04 · LAX 15:04 · JFK 18:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.