Is there a way to retain the undo levels, even when the buffer is not
loaded in any windows/tabs? Right now, whenever I open another file in
a window, the previous file loses it's undo levels, even though it is
still inside the buffer list.
Just to make sure I understand, you're talking about preserving
undo (not the 'undolevels' setting, which is global) across
buffer abandonment. To do this, it sounds like you want the
'hidden' setting:
:set hidden
This has some other effects, such as not requiring you to save
when you leave the buffer (though if you try and quit Vim
entirely with such unsaved buffers hidden, it will squeal)
However, it should allow you to keep your undo history even if
you close the tab/window/buffer.
For more info, you can read up at
:help 'hidden'
-tim