Vim:将光标移动到最后一个位置 [英] Vim: Move cursor to its last position

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

问题描述

在 (g)Vim 中是否可以将光标移动到先前的位置(在正常模式下)?在以前的光标位置列表中来回循环的东西是理想的.但也只需切换到最后一个位置就足够了(类似于带有目录的 bash 中的 cd -).

Is it possible in (g)Vim to move the cursor to its previous position (while in normal mode)? Something to cycle back and forth in the list of previous cursor positions would be ideal. But also just to switch to the last location would suffice (something like cd - in bash with directories).

这是一个小示范:

line |1| <- cursor position
line 2
line 3
line 4

假设我做了 2j,现在是这样:

And suppose I did 2j, here's how it is now:

line 1
line 2
line |3| <- cursor position
line 4

现在我想按一些东西(显然除了 2k 之外)移回第一个位置,可能还会移动到以前的位置.

Now I'd like to press something (other than 2k obviously) to move back to the first position and possibly to previous positions.

推荐答案

最快的方法是:

''

(两个撇号)或:

``

(两个反引号).请注意,不同之处在于反引号指向行上的相同位置,而撇号指向行的开头.在英式键盘上,撇号更容易使用,所以我倾向于使用那个.有很多这样的有用标记,请参阅:help mark-motions.

(two backticks). Note that the difference is that the backtick goes to the same location on the line, whereas the apostrophe goes to the start of the line. On a UK keyboard, the apostrophe is more accessible, so I tend to use that one. There are loads of useful marks like this, see :help mark-motions.

对于其他一些动作(我认为不是 2j),还有跳转列表可以让您在多个动作之间来回导航.CtrlOCtrlI 执行此导航,但请参阅 :help jump-motions 了解更多信息.

For some other motions (not 2j I think), there's also the jump-list that lets you navigate back and forth among a number of motions. CtrlO and CtrlI do this navigation, but see :help jump-motions for more information.

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

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