保存する前にバッファ内の何かを変更するvimスクリプトがあります。
ただし、このスクリプトは VIM をトリガーして、以下のような通知を出力します。
"file.txt" 112L, 4391C written
1 change; before #46 0 seconds ago
Press ENTER or type command to continue
どうすればそれを止めることができますか?
ここでスクリプト:
-- script.lua
function update()
local b = vim.buffer()
for i = 1, 10 do
local line = b[i]
if line and line:match('updated_on:.*') then
b[i] = line:gsub('updated_on:.*', 'updated_on: '..os.date())
break
end
end
end
function undo()
vim.command'call UndoIt()'
end
vim.command"autocmd BufWritePre * lua update()"
vim.command"autocmd BufWritePost * lua undo()"
-- script.vim
function! UndoIt()
let l:winview = winsaveview()
undo
call winrestview(l:winview)
endfunction