list - Vim - jump back to previous position when moving multiple lines at once
问题描述
When I use Vim, I often times use motions commands when moving lines.
For example if I want to move 20 lines down, I press 20j
.
Now after having "jumped" 20 lines down, if I want to go back again to my previous position, I have to enter 20k
.
Is there a way to jump to my previous position without typing 20k
?
For example, by somehow adding the previous position to Vims jump list, then I could use <c-o>
to jump back.
(By the way, I only want to jump back when I move more that one line at once).
解决方案
这里的问题是,j
而k
不是“跳跃”。当你这样做时,20j
你真的在做jjjjjjjjjjjjjjjjjjjj
,但速度很快,所以你必须将这些任意动作转化为适当的跳跃<C-o>
才能工作。如何做到这一点在下面解释:help jumplist
:
您可以通过使用“m”设置'标记来显式添加跳转。
在实践中:
m'20j
然后<C-o>
或''
或``
返回。
不过,还有一些更聪明的移动方式,不需要你计算行数,而且是实际的跳跃,比如:help /
and :help ?
。
推荐阅读
- javascript - eslint - vscode 的可选链接错误
- google-apps-script - 如何使 Google Apps 脚本库始终提供最新版本
- python - 尝试填写用户名时出现硒 NoSuchElementException
- javascript - 获取 JavaScript 中反斜杠 (\) 后的字符串值
- tableau-api - 包含当前值的移动平均线
- python - 模块“随机”没有属性“随机”
- javascript - 在 React 中加载微调器
- dns - BIND9 - 我可以将简单的主机名映射到域名吗?
- verilog - 使用 reg[127:0] temp[0:999] 等大型数组是否可以使芯片尺寸更大?
- sql-server - SQL,选择组中的最大数量