vim 如何对齐文本?

5cnsuln7  于 2023-08-05  发布在  其他
关注(0)|答案(2)|浏览(138)

可以格式化以下文本,以便文本之后:是否在特定列中(如70)?

body:
X  width:                                    100%
// This is comment
   min->
X    width:  960px
   a:
     &:hoover:
X      family:                       $main_fonts
   background->
X    image:                                  url('img/image.png')
X    position:     top center
X    repeat:         repeat
X  color: #000

字符串
但是只针对包含X的行(前面的X只是为了显示要格式化的行,它不在真实的的文件中)。我试着用查尔斯·坎贝尔的Align,但没有运气:(
生成的文本应该如下所示:

body:
  width:                                             100%
// This is comment
   min->
    width:                                           960px
   a:
     &:hoover:
      family:                                        $main_fonts
   background->
    image:                                           url('img/image.png')
    position:                                        top center
    repeat:                                          repeat
  color:                                             #000

g0czyy6m

g0czyy6m1#

在带有Tabular插件的vim中,使用V逐行直观地选择要格式化的区域,然后:'<,'> Tabular /:\s+\zs/l0 l70(spiiph是正确的:)

toiithl6

toiithl62#

使用以下正则表达式:
第一个月

:%s/^.*:\zs/ /g * 以确保匹配最后的:字符 *
然后::%s/\%>25c\s\{2,}//g
最好的问候!

相关问题