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>

Swap file .env.swp already exists
Swap file xxx already exists

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)