使用 t 和 f 移动光标,使用单词作为参数,vim

发布于 2024-12-06 07:06:48 字数 118 浏览 3 评论 0原文

vim 中是否可以使用 tf 前进(或者以其他方式使用 TF ),但是使用单词作为参数?

Is it possible in vim to move forward with t and f (or in the other way with T and F), but using words as a parameter ?

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

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

发布评论

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

评论(3

格子衫的從容 2024-12-13 07:06:48

/word 怎么样?

它可以像其他任何东西一样与运算符组合:

the lazy cow jumped over the high moon

光标位于开始处,d/highEnter

high moon

奖励

此外,您可能有兴趣学习一些 ex 模式命令,例如:

the lazy cow jumped over the high moon
the hazy cow jumped over the high moon
the noble cow jumped over the high moon
the crazy cow jumped over the high moon

现在输入

:g/azy/ norm! /jumped<CR>d/high/e<CR>

(注意: 表示CvCm 表示回车键 (^M))

结果:

the lazy cow  moon
the hazy cow  moon
the noble cow jumped over the high moon
the crazy cow  moon

/e 标志实现包含 行为类似于 f;要获得 'till 行为:

:g/azy/ norm! /jumped<CR>d/high/<CR>

结果:

the lazy cow high moon
the hazy cow high moon
the noble cow jumped over the high moon
the crazy cow high moon

What about /word?

It can be combined with operators just like anything else:

the lazy cow jumped over the high moon

cursor at start, d/highEnter:

high moon

Bonus

Also, you might be interested in learning some of the ex mode commands like that:

the lazy cow jumped over the high moon
the hazy cow jumped over the high moon
the noble cow jumped over the high moon
the crazy cow jumped over the high moon

Now enter

:g/azy/ norm! /jumped<CR>d/high/e<CR>

(Note: <CR> denotes C-vC-m for the enter key (^M))

Result:

the lazy cow  moon
the hazy cow  moon
the noble cow jumped over the high moon
the crazy cow  moon

The /e flag achieves inclusive behaviour like with f; To get 'till behaviour instead:

:g/azy/ norm! /jumped<CR>d/high/<CR>

Result:

the lazy cow high moon
the hazy cow high moon
the noble cow jumped over the high moon
the crazy cow high moon
触ぅ动初心 2024-12-13 07:06:48

尝试使用 *# 搜索光标下单词的实例。您会注意到它将模式设置为 \,因此您可以使用类似的模式来查找所需的单词,并由单词边界字符包围。

Try using * or # to search for instances of the word under the cursor. You’ll notice that it sets the pattern to \<foobar\>, so you can use a pattern like that to find the word you want, surrounded by word boundary characters.

青衫负雪 2024-12-13 07:06:48

您可能想使用 /word 进行此类搜索。

set incsearch 也可能有帮助。

You probably want to use /word for that kind of search.

set incsearch might also help.

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