Vim -- 阻止大括号导航留下标记

Vim -- 阻止大括号导航留下标记

花括号 当使用花括号导航时,{, }, 在段落之间移动,覆盖“最后跳转”标记(可通过 访问'')。如果这个标记保持不变,我会发现它更有用。有没有办法像这样配置vim?

答案1

您可以使用该keepjumps命令。从:h :keepjumps

                            *:keepj* *:keepjumps*
:keepj[umps] {command}
            Moving around in {command} does not change the |''|,
            |'.| and |'^| marks, the |jumplist| or the
            |changelist|.
            Useful when making a change or inserting text
            automatically and the user doesn't want to go to this
            position.

所以在你的情况下,你会想要

nnoremap } :keepjumps normal! }<cr>
nnoremap { :keepjumps normal! {<cr>

或者,如果您希望它也适用于视觉模式(您可能会这样做):

xnoremap } :<C-u>keepjumps normal! gv}<cr>
xnoremap { :<C-u>keepjumps normal! gv{<cr>

相关内容