Vim 滚动时保持光标位置 [英] Vim keep cursor location while scrolling

查看:41
本文介绍了Vim 滚动时保持光标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在滚动时使 Vim/gVim 中的光标位置保持在屏幕外?类似于许多 Windows 编辑器.
我知道标记,并且确实使用它们.我也知道'.'标记(最后编辑位置),但正在寻找其他想法.我之所以这么问是因为有时我想将光标保持在某个位置,使用鼠标滚轮滚动到另一个位置,然后只需按一个箭头键或其他东西就可以让我回到那个位置.

Is there a way to keep the cusror location off-screen in Vim / gVim while scrolling? Similar to many Windows editors.
I know about marks, and do use them. I also know the '.' mark (last edit location), But looking for other ideas. I'm asking this because sometimes i want to keep the cursor at some location, scroll to another place using the mouse-wheel, and then just press an arow key or something to get me back to that location.

推荐答案

没有.vim 是一个控制台应用程序,因此将光标移出屏幕并没有什么意义(这是可能的,但只会令人困惑)

No. vim is a console application, so it doesn't really make sense to have the cursour off-screen (it's possible, but would just be confusing)

另一种解决方案,转述来自 来自 comp.editors 的线程的帖子:

An alternative solution, to paraphrase posts from this thread from comp.editors:

Ctrl+o 转到上一个光标位置,Ctrl+i 转到下一个(如撤销/重做动作)

Ctrl+o goes to the previous cursor location, Ctrl+i goes to the next (like undo/redo for motions)

标记似乎是另一种解决方案..

Marks seem like the other solution..

另外,使用标记.标记以字母命名.比如打字ma记住标记 a 下的当前位置.要跳转到包含标记 a 的行,输入'a.到确切的位置使用`a.

Also, use marks. Marks are named by letters. For instance typing ma remembers the current location under mark a. To jump to the line containing mark a, type 'a. To the exact location use `a.

小写字母标记是每个文件.大写字母标记是全局的;`A 将切换到包含标记 A 的文件的确切位置.

Lower-case-letter marks are per-file. Upper-case-letter marks are global; `A will switch to the file containing mark A, to the exact location.

基本上ma,移动,然后`a 跳回来.

Basically ma, move around, then `a to jump back.

保罗建议的另一种选择,

Another option which Paul suggested,

gi 命令将 Vim 切换到插入模式并将光标置于与上次停止插入模式相同的位置.

gi command switches Vim to Insert mode and places cursor in the same position as where Insert mode was stopped last time.

这篇关于Vim 滚动时保持光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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