On Git bash windows, I was editing .bash_profile file and then I decided not to save and closed the bash console. Now when I try to open the .bash_profile using vim, I get E325: Attention error. What should I do to fix this?
Using the swapfile to recover your work doesn't automatically delete it, but if the recovery was successful, it's fine to delete it. Run vim on the file again and you should still get a swapfile dialog, but this time warning that the file is "NEWER than swap file".
To recover a file, simply open the original file. vim will notice that there is already a . swp file associated with the file and will give you a warning and ask what you want to do. Assuming you have the required privileges to write to the file, "recover" should be one of the options given.
Swap files store changes you've made to the buffer. If Vim or your computer crashes, they allow you to recover those changes. Swap files also provide a way to avoid multiple instances of Vim from editing the same file.
By closing the console without exiting Vim first, the Vim process got killed, and Vim didn't have a chance to properly shut down. Vim uses swap files to store the last unpersisted changes to a buffer to avoid data loss in case of a crash; you can read the whole story at :help E325
.
In your case, as you've consciously closed the console, there probably weren't any pending changes to your .bash_profile
[worth saving]. (But there's still the swap file!) Therefore, when prompted
Swap file ".bash_profile.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort, (D)elete it:
answer with D to remove the outdated swap file. Alternatively, you can also search for the .bash_profile.swp
(by default, it resides in the same directory as the edited file, likely $HOME
in your case) and delete it manually. (It's hidden; use ls -a
in Bash, or Windows Explorer.)
In the future, please exit Vim (:qall[!]
) before closing the console it runs in, to allow for a clean shutdown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With