Vim/MacVim:当我用鼠标滚动时,文本光标也会移动!

发布于 2024-10-02 17:33:15 字数 237 浏览 1 评论 0原文

过去几周我已经习惯了 Vim/MacVim。我似乎遇到的主要问题之一是当我使用鼠标滚动时(特别是当我尝试选择大部分文本时),文本插入光标也会移动并且不会停留在原来的位置(就像在 TextMate 中一样)例子)。这意味着我选择了一大段文本,当我向上滚动以查看我的选择时,光标会移动,这会与我所做的选择混淆。

我确实意识到我应该习惯使用视觉模式进行文本选择,而且我也有点习惯,但有时它是使用鼠标的最佳工具。

有办法解决这种行为吗?

I've been getting used to Vim/MacVim for the last few weeks. One of main problems I seem to be having is when I scroll around using the mouse (especially when I'm trying to select large portions of text) the text insertion cursor moves too and doesn't stay where it was (like in TextMate for example). This means I've selected a large piece of text, when I scroll back up to review my selection the cursor will move which messes with the selection that I've made.

I do realise I should get used to text selection with visual mode, and I am one bit of a time, but sometimes it's the best tool to use the mouse.

Is there a way of fixing this behaviour?

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

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

发布评论

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

评论(2

我早已燃尽 2024-10-09 17:33:15

:helpscrolling 告诉你:

这些命令移动的内容
窗户。如果光标位置是
移出窗口,光标位于
移到窗户上(与
其周围的“滚动”屏幕线)。

所以基本上我想说的是,当你滚动时,不可能将光标留在原来的位置。光标在窗口中始终可见,因此您的视觉选择将会扩展。

也许您想要xnoremap; 与 ScrollWheelDown 相同。然后使用 gv 恢复您的选择。

:help scrolling tells you:

These commands move the contents of
the window. If the cursor position is
moved off of the window, the cursor is
moved onto the window (with
'scrolloff' screen lines around it).

So basically I would say that it is not possible to leave the cursor where it was when you are scrolling. The cursor is always visible in your window, and therefore your visual selection will extend.

Probably you would like to xnoremap <ScrollWheelUp> <esc><ScrollWheelUp> and same for ScrollWheelDown. Use then gv to restore your selection.

已下线请稍等 2024-10-09 17:33:15

我制作了一个关于 Vim 的更改列表和跳转列表 的截屏视频,它解决了以下问题Vim 的光标始终在屏幕上。更改列表维护文档中您进行编辑的所有位置的列表。您可以分别使用命令 g;g, 在列表中前后移动。或者,如果您想将光标放回上次编辑的位置并进入插入模式,只需按 gi 即可。

正如 Alois Cochard 指出的那样,当您处于可视模式时,o 键非常有用。它将光标在所选内容的开头和开头之间移动。因此,如果您的选择大于屏幕,它会将您从一端移动到另一端。

I made a screencast about Vim's changelist and jumplist which addresses the issue of Vim's cursor always being on screen. The changelist maintains a list of all of the places in your document where you have made an edit. You can move back and forward through the list with the commands g; and g, respectively. Or if you want to put your cursor back on the last place where you made an edit and go into insert mode, just press gi.

As Alois Cochard pointed out, the o key is very useful when you are in visual mode. It moves the cursor between the start and the beginning of your selection. So if your selection is larger than your screen, it will move you from one end to the other.

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