我喜欢 ‘.
vim中的命令.来自:help’.:
'. `.
[Jump to] the position where the last change was made. The position is at or near where the change started.
好.但这是我的问题:我使用autocmd函数在我的文件头中添加“最后修改”行.所以,每次写完之后,’.我没有带到我的“真正的”最后一次更改,而是我的文件标题.我目前的解决方案是我试着记住用ma标记我当前的编辑点,所以我可以’回到它.我有时会忘记,即使我记得,也是另外几次按键.
我理想的解决方案是某种命令,告诉vim不要记住动作.我可以在autocmd函数跳转之前发送此命令,写入最后修改的行,然后在autocmd函数完成后取消它.那样,与’相关的位置.不会改变.但是,我对任何其他更高效的选项持开放态度.
如果你想看到它,这是autocmd的作用:w.
function! UpdateHeader() let b:winview = winsaveview() " This is where I'd put the command to ignore future movements "The periods concatenate all the arguments into one command. "Silent! suppresses errors,usually 'pattern not found' "The 1,6g means search only lines 1 thru 6 "Search for File Name: followed by anything "'s'ubstitute "Substitute in 'File Name: ' and the results of the expand command,on the "current filename execute "silent! 1," . 6 . "g/File Name:.*/s//File Name: " . expand("%") execute "silent! 1," . 6 . "g/Last Modified:.*/s//Last Modified: " . strftime("%d-%m-%Y") " This is where I'd put the command to start remembering movements again call winrestview(b:winview) endfunction
解决方法
您可以在autocmd中使用:keepjumps {command}.
请参阅:help:keepjumps.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。