Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Ubuntu, Linux, Unix vi error: swap file .swp already exists

Command that gave me error:
vi .env or vi <any file name that starts with a “.” that means it’s a hidden file>

Error:
Swap file .env.swp already exists
or
Swap file xxx already exists

Solution:
ls -A (This will show you if a .swp file really existd)
rm .filename.swp (This will delete the .swp file which was generated while you closed the session accidentally while editing the original file)

Verify the solution:
ls -A (Now you won’t see the .swp file that you deleted using the above command)

Chetan