【发布时间】:2011-09-26 12:24:39
【问题描述】:
是否可以在 vim 中使用 t 和 f(或以其他方式使用 T 和 F)前进,但使用 words 作为参数?
【问题讨论】:
标签: vim text-cursor
是否可以在 vim 中使用 t 和 f(或以其他方式使用 T 和 F)前进,但使用 words 作为参数?
【问题讨论】:
标签: vim text-cursor
/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>
(注意:<CR> 表示 C-vC-m 为回车键 (^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
【讨论】:
/(和?)与量词(和其他运算符)结合起来!
:global、命令范围、模式修饰符。有时稍微挑逗一下就足够了——它会触发科技人员的好奇心基因,不是吗?
尝试使用 * 或 # 搜索光标下单词的实例。您会注意到它将模式设置为\<foobar\>,因此您可以使用类似的模式来查找您想要的单词,并由单词边界字符包围。
【讨论】:
您可能希望使用/word 进行此类搜索。
set incsearch 也可能有帮助。
【讨论】: