Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2009
    Location
    Massachusetts, MA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to get rid of .swp files in Unix?

    My directories keep getting cluttered with hidden .swp files, and I can't seem to get rid of them. This is especially annoying as whenever I try to open a text file in vi it opens the .swp for that text file instead. Whenever I try to remove the .swp files, I get a "No such file or directory" error message.

  • #2
    Regular Coder primefalcon's Avatar
    Join Date
    Aug 2008
    Location
    /home/primefalcon/
    Posts
    678
    Thanks
    8
    Thanked 39 Times in 39 Posts
    Quote Originally Posted by yellow_mongoose View Post
    My directories keep getting cluttered with hidden .swp files, and I can't seem to get rid of them. This is especially annoying as whenever I try to open a text file in vi it opens the .swp for that text file instead. Whenever I try to remove the .swp files, I get a "No such file or directory" error message.
    yout swp files are temp files that get written to when your editing a file, then when you save it it dumps the contents of the swp file into the main file, this is why when your done ith vi and you want to close it you enter the command /w

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Unless Vi crashes while you are using it, after you close the file, the matching swap file should go away on its own. The swap files server an important purpose so that if the program does crash or your computer loses power, or anything in between, you won't lose the work you've done (or at least not all of it).
    OracleGuy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •