防止Vim记住改变
发布时间:2020-12-15 21:59:13 所属栏目:安全 来源:网络整理
导读:我喜欢 ‘. vim中的命令.来自:help’.: '. `. [Jump to] the position where the last change was made. The position is at or near where the change started. 好.但这是我的问题:我使用autocmd函数在我的文件头中添加“最后修改”行.所以,每次写完之后
我喜欢 ‘.
vim中的命令.来自:help’.:
'. `.
好.但这是我的问题:我使用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. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容