vim 在一行的块选择内替换

发布于 2025-01-07 15:17:40 字数 59 浏览 4 评论 0原文

我在乳胶文件中有以下表达式

\begin{dfn} \tag{Diagram $
              

I have the following expression in a latex file

\begin{dfn} \tag{Diagram $????$ over a trisp $\Delta$}
          \label{dfn:Diagram D over a trisp Delta}

now i want to substitute all the spaces in the brackets on the second line with :.
my idea was to visual select the expression by v% while being on one of the brackets and then :s/\ /:/g but this replaces all whitespaces and results in

::::::::::::::\label{dfn:Diagram:????:over:a:trisp:Delta}

which results in the task of removing the : before the \label{…}
as vim is a very powerful editor - there should be an easier way, that I don't know yet.

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

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

发布评论

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

评论(1

趁年轻赶紧闹 2025-01-14 15:17:40

转到第一个 {,按 v,按 %。这将直观地选择 {} 之间的文本。然后按 : 并在迷你栏中输入 s/\%V\ /:/g。请参阅此说明:

请注意,否则g 将替换当前行上的所有内容。

Go to the first {, press v, press %. This will visually select the text between { and }. Then press : and enter s/\%V\ /:/g in your minibar. See this for explanation:

Note that otherwise g will replace all on the current line.

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