I have an issue opening one of the config file, each time when I try to edit it by giving sudo vi XX file name XX it says:

"Swap file ".config.ini.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:"

Then I see that there is another config file in my dir with same with extension "filename.ini~"

Can anyone please let me know on how to take the back up for in file and delete it the duplicate one.

Thanks much!

  • 2
    Possible duplicate of Unable to delete file – Panther May 17 '16 at 16:36
  • 1
    recover and save the file first. – Panther May 17 '16 at 16:36
  • vim tends to create .swp files as backup. Just rm .config. ini. swp file , and reopen .config. ini fil and you will be ok. As for filename. ini~ those are backup by nano editor if I'm not mistaken – Sergiy Kolodyazhnyy May 17 '16 at 16:52

The tilde filename.ext~ are vi/vim backup files. They are a copy of a file you've edited as it was before you opened it in vim.

The .swp files are swap files, and they act as locks, preventing you from editing the file in another instance of vim. These files stick around if your vim instance crashes while editing.

If you're sure you don't need to restore any edits before the crash, you can delete them.

For the tilde files, if you want to restore from them, just do mv config.ini~ config.ini. If you want to delete them (all) within your current working directory: find . -name "*~" | xargs rm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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