【问题标题】:Moving cursor with t and f, using word as parameter, vim使用 t 和 f 移动光标,使用 word 作为参数,vim
【发布时间】:2011-09-26 12:24:39
【问题描述】:

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

【问题讨论】:

    标签: vim text-cursor


    【解决方案1】:

    /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>
    

    (注意:&lt;CR&gt; 表示 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
    

    【讨论】:

    • 添加了额外的示例,因为想要重复执行此操作很常见
    • 你的例子很棒!但我无法理解 ex 模式命令。尽管如此,我一直在寻找将/(和?)与量词(和其他运算符)结合起来!
    • 是的,ex 命令确实结合了很多强大的工具::global、命令范围、模式修饰符。有时稍微挑逗一下就足够了——它会触发科技人员的好奇心基因,不是吗?
    • 现在完全理解这个例子了!
    • 什么是规范!
    【解决方案2】:

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

    【讨论】:

    • 感谢您对边界的见解,但仍然不是我想要的。
    【解决方案3】:

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

    set incsearch 也可能有帮助。

    【讨论】:

    • 谢谢。是的,我经常这样做,但我真的需要知道将其与运动和其他操作符结合起来。
    猜你喜欢
    • 2014-02-22
    • 1970-01-01
    • 1970-01-01
    • 2011-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多