I have problem with .bashrc file I can't save changes by command :wq. When I put command to terminal vim .bashrc I have message like below. And when I choose "Edit" I am in .bashrc but :wq isn't save and close file

I found a swap file named ".bashrc.swp"
    owned by browsers Date: Thu Feb 18 11:05:15 2016
        file name: darek ~ / .bashrc
          changed: YES
         Member: darek host name: darek-SATELLITE-L850-1LE
         Process ID: 5119
When opening the file ".bashrc"
               Date: Tue Feb 16, 2016 8:42:37 p.m.

(1) Another small program be editing the same file. If this is the case,
     be careful not to end up with two different instances of the same
     file when making changes. Quit, or continue with caution.
(2) An edit session for this file crashed.
     If so, use ": recover" or "vim -r .bashrc"
     to recover the changes (see ": help recovery)").
     If you've already done so, you remove the swap file ".bashrc.swp"
     to avoid this message.

The swap file ".bashrc.swp" already exists!
[O] create Read-Only, (E) dit although Re (d) create (D) elete (E) xit, (R) eject:

You probably exited editing that file in a way such that the system did not finish saving it.

Easy solution: remove the swap file as shown in the message " If you've already done so, you remove the swap file ".bashrc.swp" to avoid this message."

Do a

ls -la .bashrc.swp

to confirm its existence and remove the file it shows with rm .bashrc.swp.

| improve this answer | |
  • Hmm I do it like You said bashrc.swp is gone and info after command vim .bashrc also but all the time I can't save it I click enter like below and nothing :/ # for virtualenwrapper export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/django source /usr/local/bin/virtualenvwrapper.sh :wq ~ – Darek Feb 18 '16 at 10:59
  • Check permissions of the file (should be rw-r-r and owner, should be you. Besides that: you need to press ESC before the :wq – Rinzwind Feb 18 '16 at 11:01
  • I use Esc, I don't know how check permission but I use gedit ~/.bashrc and now I can edit it. – Darek Feb 18 '16 at 11:12

.bashrc.swp existence suggest that your vim session was terminated abnormally, may be crashed, killed it without closing, putty session lost etc.

This is the vim way of telling that you can recover your unsaved changes. Theory apart, there are multiple ways to fix the irritation notice.

vim bashrc then R to recover. After recovering, oh yes the fun part starts now,


Then the same dialogue will come. This time, you select D to delete the swap file.

Secondly, you can delete .bashrc.swp by using `rm -f .bashrc,swp.

| improve this answer | |

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.