Vim 中的 f 和 t 命令有什么作用? [英] What do the f and t commands do in Vim?

查看:71
本文介绍了Vim 中的 f 和 t 命令有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ft 命令在 vim 中做了什么以及它们是如何工作的?

What do f and t commands do in vim and exactly how they work?

推荐答案

遇到此类问题的第一站应该是 vim 的内部帮助,:h f:h t.但是,在这种情况下,如果没有示例,这些条目有点神秘.假设我们有这一行(^ = 光标位置):

Your first stop with questions like these should be vim's internal help, :h f and :h t. However, in this case, those entries are a bit cryptic without an example. Suppose we had this line (^ = cursor position):

The quick brown fox jumps over the lazy dog.
^

这些命令在一行中查找字符.所以 fb 会将光标放在此处:

These commands find characters on a line. So fb would place the cursor here:

The quick brown fox jumps over the lazy dog.
          ^

tf 类似,但将光标放在前面的字符上.所以 tb 会给你:

t is like f but places the cursor on the preceding character. So tb would give you:

The quick brown fox jumps over the lazy dog.
         ^

您可以将这些命令记为 find 和 till.此外,您可以在命令前添加一个数字以移动到该字符的第 n 个出现处.例如,3fb 将移动到光标右侧的第三个 b.我的例句只有一个b,所以光标根本不会移动.

You can remember these commands as find and till. Also, you can prepend the commands with a number to move to the nth occurrence of that character. For example, 3fb would move to the third b to the right of the cursor. My example sentence only has one b though, so the cursor wouldn't move at all.

这篇关于Vim 中的 f 和 t 命令有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆