From: sev Date: Fri, 6 Dec 2024 06:58:31 +0000 (-0600) Subject: vim: manually write undo with suda X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/commitdiff_plain/3dc35911ab4452bb214c0d503e9d59cc10797a3b?ds=sidebyside vim: manually write undo with suda --- diff --git a/etc/vim/.vimrc b/etc/vim/.vimrc index b59d19e..5e027bd 100644 --- a/etc/vim/.vimrc +++ b/etc/vim/.vimrc @@ -203,5 +203,62 @@ function s:SudaSettingsRestore() endif endif endfunction +function s:SudaWriteUndo() + let p = expand('')[7:] + if has('win32') || !&undofile || !filereadable(p) + return + endif + let p = resolve(p) + " XXX: comments are from :help backupdir to mark implementation details + let x = &undodir + " For backwards compatibility with Vim version 3.0 a '>' at the start + " of the option is removed. + if stridx(x, '>') == 0 + let x = x[1:] + endif + " To include a comma in a directory name precede it with a backslash. + for u in split(x, '\v\\@1