I use a vim persistent undo setup as follows, which have worked all that way here.

set undofile
set undodir=~/.vim/undodir

However now I'm facing a problem when the undofile became too long, notice that an undofile has a name in the form of absolute path like %home%user%directory%...%directory%file that means if your file has a big name, is under a big path directory or both, the chances for reaching the linux file name max length will be higher. In my case, when try to save the open file it raises the error:

E828: Cannot open undo file for writing: /home/user/.vim/undodir/%home%user%workspace%%app%javascript%packs%domains%components%grid%column_cell_factory%inspection_cell_factory.jsx

How can I manage in order to keep my persistent undo working even for these situations?


A satisfactory workaround could be a way for vim dynamically detect the error and then change the store path for a local aside the current file.


This is not my real filename, I removed username and others personal information intentionally, at the end they are not relevant and don't contain any special char. The file length is 160, and the whole path with the folder it should be stored is 189 length.


1 Answer 1


There is a plugin that rewrites the undo file as a path instead of one long filename:


So instead of %home%user%directory%...%directory%file you get /home/user/directory/.../directory/file for your undo file.

  • Maybe should we mention that this answer is inspired from this one. Oct 7, 2023 at 4:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.