在neovim中拉动一个单词时,请忽略落后的空间

发布于 2025-02-09 02:06:01 字数 313 浏览 1 评论 0原文

因此,我在单词(YW)拉动时的问题是它也复制了尾随空间:

示例: 对此进行YW:

‖Hello World

导致复制Hello

但同样适用于:

‖LongVariableName                        = 'SomeValue';

复制longvariablename的结果

是否有一种方法可以使我复制而不复制任何空间? (对我来说,在复制单词时很有意义)

So my issue when yanking a word (yw) is that it copies the trailing spaces as well:

Example:
Doing a yw on this:

‖Hello World

Results in copying Hello

But the same applies to:

‖LongVariableName                        = 'SomeValue';

Results in copying LongVariableName

Is there a way to make as such I copy without copying any space? (which for me makes sense when copying words)

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

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

发布评论

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

评论(1

夜清冷一曲。 2025-02-16 02:06:02

您可以使用yiw拉动“内字”文本对象(yaw将包括一个额外的空间)。请参阅:帮助文本对象

文本对象的一个​​不错的功能是,光标可以在对象上的任何位置(在这种情况下为单词)可以正常工作。

vim中有许多文本对象:

  • is表示内部句子
  • ip表示内部段落
  • i)表示内括号

等等!

另外,下面的评论@doktoroswaldo指出,您还可以使用ye从当前位置拉动,直到单词结束没有空间,e是当前的单词w是下一个单词的开始(这不是文本对象,因此在换句话中重复它会要求光标处于相同的位置)。

You can use yiw to yank the 'inner word' text object (yaw would include an additional space). See :help text-objects.

A nice feature of text objects is that the cursor can be anywhere on the object (in this case the word) for it to work.

There are many text objects in vim:

  • is means inner sentence
  • ip means inner paragraph
  • i) means inner parentheses

And many more!

Also the comment below by @DoktorOSwaldo points out that you can also use ye to yank from the current position until the end of the word without the space, e is the end of the current word, w is the start of the next word (this is not a text object, so repeating it on other words would require the cursor to be in the same position).

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