如何设置vim地图不改变跳转列表?
[first line]
int test() {
a
b
c
d
{
e
f
g
}
}
- 当前与
f
一致的光标。 - 如果我按
[[
>,光标将转到[第一行]
。 - 我想要光标goto
int test(){
。因此,我设置了一个映射:nnoremap [[] [%
。 - 地图命令效果很好,有一个问题:如果我按
ctrl+o
,光标将转到最后一行}
。 - 我想要的是光标可以使用
f
返回到线路。
我尝试了nnoremap [[:keepjump normal] [%< cr>
,但它不起作用。
我该如何实施?
- 按
[[
与int test(){
制作光标goto line。 - 按
ctrl+o
使光标跳回去。
我的VIM版本是VI改进的7.4
[first line]
int test() {
a
b
c
d
{
e
f
g
}
}
- The cursor in currently in line with
f
. - If I press
[[
, the cursor will go to[first line]
. - I want cursor goto
int test() {
. So I set a mapping:nnoremap [[ ][%
. - The map command works good, with one problem: if I press
CTRL+O
, cursor will go to the last line}
. - What I want is the cursor to go back to the line with
f
.
I tried nnoremap [[ :keepjumps normal ][%<CR>
, but it does not work.
How can I implement this?
- press
[[
make cursor goto line withint test(){
. - press
CTRL+O
make cursor jump back.
My vim version is Vi IMproved 7.4
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
跳跃列表的工作方式经常被误解。跳跃存储在跳跃列表中,仅记录了您制作的“跳跃”的 Origin 而不是其目的地。这意味着
:help:keepjumps
应该用于防止将新的 Origin 添加到跳跃列表中。为了
&lt; co&gt;
跳回原点f
,该来源必须存在于跳跃列表中>必须遗漏。做:
您有效地阻止了 arourt
f
和 orient}
要添加到跳跃列表 中。您可以通过移动
] [
从中移动
:keepjumps 命令:The way the jump list works is very often misunderstood. A jump, as stored in the jump list, only records the origin of the "jump" you made, not its destination. This means that
:help :keepjumps
is supposed to be used to prevent a new origin to be added to the jump list.In order for
<C-o>
to jump back to the originf
, that origin must be present in the jump list so it's only the origin}
that must be left out.In doing:
you are effectively preventing both the origin
f
and the origin}
to be added to the jump list.You can fix your mapping by moving
][
out of the:keepjumps
command: