VIM:为什么替换选项卡与插入模式选项卡不同

发布于 2025-01-05 17:55:15 字数 355 浏览 2 评论 0原文

我有一个很大的空格缩进文件。我通过以下方式用制表符替换了空格:

:%s/    /<Ctrl-Tab>/g

但是,当我 set list 时,我看到替换制表符给出字符 ^T 而不是我配置的 .___< /code> (来自 set listchars=tab:._,trail:.)。事实上,如果我在插入模式下插入一个选项卡,那么它确实会显示正确的 .___,所以显然这两个字符是不同的。

如何使用 :s 插入“普通”选项卡?谢谢。

I have a large space-indented file. I replaced the spaces with tabs by way of:

:%s/    /<Ctrl-Tab>/g

However, when I set list I see that the replacement tabs give character ^T instead of my configured .___ ( fromset listchars=tab:._,trail:.). In fact, if I insert a tab in Insert mode then it does show the proper .___, so obviously the two characters are different.

How can I insert a "normal" tab with :s? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单调的奢华 2025-01-12 17:55:15

在表达式中使用“\t”:

:%s/    /\t/g

此外,您可能希望使用 :retab 替换文件中的空格和制表符,通过设置,例如:

:set ts=8
:set noexpandtab
:retab!

Use "\t" in the expression:

:%s/    /\t/g

Also, you may want to replace spaces with tabs in the file with :retab, by setting, eg:

:set ts=8
:set noexpandtab
:retab!
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文