Vim 中的 b 和 B 有什么区别? [英] What's the difference between b and B in Vim?

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

问题描述

我用谷歌搜索了一下,上面是这么说的:

I googled and that's what it says:

要返回一个单词,使用 b.再一次,B 将在 Vim 认为的单词中包含更多字符.

To go back a word, b is used. Once again, B will include more characters in what Vim considers a word.

我不明白 B 与 b 有什么不同.你能举个例子让我清楚明白吗?谢谢.

I didn't understand what B does different from b. Can you give me an example to make it clear for me to understand? Thanks.

实际上我对此感到疑惑,因为在在线 vim 游戏 中,我试图回到 WORDS从 !与 b,但它没有用.但是,当我在计算机上安装 Vim 的情况下尝试它时,它与 b 一起工作.那么这仅仅是为了让玩家借助线索使用B吗?

Actually I wonder this because in the online vim game, I tried to go back to WORDS from ! with b, but it didn't work. However when I tried it with Vim installed in my computer, it worked with b. So is this only for to make player use B with the help of clue?

游戏截图如下:

推荐答案

像大多数大写移动对一样,b 按单词移动,但 B 按单词移动.不同之处在于,vim 将单词"视为字母、数字和下划线(您可以使用 iskeyword 设置对其进行配置),但WORD"总是 任何不是空白的东西.

Like most of the capitalized movement pairs, b moves by word, but B moves by WORD. The difference is that vim considers a "word" to be letters, numbers, and underscores (and you can configure this with the iskeyword setting), but a "WORD" is always anything that isn't whitespace.

鉴于此:

foo-bar-baz

如果您的光标在 z 上并按下 b,光标将移回 baz 的开头,然后移动到连字符,然后回到 bar 的开头,依此类推.每个对 vim 来说都是不同的词":foo-bar-baz.

If your cursor is on the z and you press b, the cursor will move back to the start of baz, then to the hyphen, then back to the start of bar, and so on. Each of these is a different "word" to vim: foo, -, bar, -, baz.

但是如果你按下B,光标会一直向左移动到f,因为foo-bar-baz非空白,因此是单个 WORD.

But if you press B, the cursor will move all the way left to the f, because foo-bar-baz is all non-whitespace and thus a single WORD.

:help word 在 vi​​m 中也解释了这一点.

:help word inside vim explains this too.

关于 vim 游戏:我认为游戏将巨石视为标点符号.尝试像这样在 vim 中输入它:

Regarding the vim game: I think the game treats boulders as punctuation. Try typing it in vim like this:

not WORDS*!

将光标放在 ! 上,b 会将您移回 *,因为 *! 是所有标点符号,因此一个词.但是那个 * 实际上是一块巨石,所以你不能移动到那里,所以什么也没发生.另一方面,B 会跳过所有不是空格的内容.

With the cursor on !, b will move you back to the *, because *! is all punctuation and thus one word. But that * is actually a boulder, so you can't move there, so nothing happens. B, on the other hand, will skip you back over everything that isn't a space.

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

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