让 Tabulize 忽略一些行并对齐其他行
Have Tabulize ignore some lines and align the others
我希望 Tabulize 忽略没有特定字符的行,然后 align/tabularize 行 ..
text1_temp = text_temp;
temporary_line;
text2 = text_temp;
最后我想要以下内容:
text1_temp = text_temp;
temporary_line;
text2 = text_temp;
// 第二个“=”相对于第一个“=”是spaced/tabbed
如果我 运行 ":Tabularize /=" 将 3 行放在一起,我得到:
text1_temp = text_temp;
temporary_line;
text2 = text_temp;
带“=”的两条线相对于中间线的长度对齐
有什么建议..?
PS:我编辑了 post 可能是为了更好地解释需求..
简单的替换怎么样,比如 :g/=/s/\t/ /g
?
如果还是不行,你也可以试试这个::g/=/s/ \+= \+/ = /g
解释:
:/g/=/s
将找到所有包含 '=' 的行,并对其进行替换。
因此,s/\t/ /g
将用空格替换制表符。这两件事结合起来就可以满足您的需求。
我不确定如何使用 Tabular directly. You might be able to use Christian Brabandt's NrrwRgn 插件来过滤掉带有 =
的行,使用 :NRP
然后 运行ning :NRM
。这将为您提供一个新缓冲区,其中仅包含带有 =
的行,因此您可以 运行 :tabularize/=/
然后保存缓冲区(:w
、:x
等).
:g/=/NRP
:NRM
:tabularize/=/
:x
最简单的选择可能是使用 vim-easy-align,它似乎开箱即用地支持这种行为。 EasyAlign使用示例(Using ga
as EasyAlign's mapping you):
gaip=
我希望 Tabulize 忽略没有特定字符的行,然后 align/tabularize 行 ..
text1_temp = text_temp;
temporary_line;
text2 = text_temp;
最后我想要以下内容:
text1_temp = text_temp;
temporary_line;
text2 = text_temp;
// 第二个“=”相对于第一个“=”是spaced/tabbed
如果我 运行 ":Tabularize /=" 将 3 行放在一起,我得到:
text1_temp = text_temp;
temporary_line;
text2 = text_temp;
带“=”的两条线相对于中间线的长度对齐
有什么建议..?
PS:我编辑了 post 可能是为了更好地解释需求..
简单的替换怎么样,比如 :g/=/s/\t/ /g
?
如果还是不行,你也可以试试这个::g/=/s/ \+= \+/ = /g
解释:
:/g/=/s
将找到所有包含 '=' 的行,并对其进行替换。
因此,s/\t/ /g
将用空格替换制表符。这两件事结合起来就可以满足您的需求。
我不确定如何使用 Tabular directly. You might be able to use Christian Brabandt's NrrwRgn 插件来过滤掉带有 =
的行,使用 :NRP
然后 运行ning :NRM
。这将为您提供一个新缓冲区,其中仅包含带有 =
的行,因此您可以 运行 :tabularize/=/
然后保存缓冲区(:w
、:x
等).
:g/=/NRP
:NRM
:tabularize/=/
:x
最简单的选择可能是使用 vim-easy-align,它似乎开箱即用地支持这种行为。 EasyAlign使用示例(Using ga
as EasyAlign's mapping you):
gaip=