Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nano - File already being edited - How do I switch to the open file?

Tags:

linux

ubuntu

nano

I have a tendency to miss-type while trying to Ctrl-X to exit nano.

Every now and then I'll try to re-open the file and get the Nano "File xxx is being edited". How do I switch back to the open file? And also, what am I miss-typing to cause this to happen?

like image 729
Tksd Avatar asked Mar 04 '20 14:03

Tksd


People also ask

How do I get out of nano editor after saving?

Quitting Nano To quit nano, use the Ctrl+X key combination. If the file you are working on has been modified since the last time you saved it, you will be prompted to save the file first. Type y to save the file, or n to exit nano without saving the file.

How do I undo in nano editor?

You can use the following shortcut keys in nano to undo or redo: Alt + U is used to undo anything in the nano editor. Alt + E is used to redo anything in the nano editor.

How to open a file in nano editor?

The Ctrl+r (Read File) shortcut allows you to read a file in the current editing session 3.Then, in the search prompt, type the file name (mention full path) and hit Enter. It will open the existing “ sample.txt ” file in the Nano editor. In this method, we will open the file right from the command line.

How do I save a nano file in Linux?

If you've already opened nano, you can press Ctrl + R to open a file. On exit ( Ctrl + X) nano will ask you whether to save the file. You can save it manually with F3. Answer n for no in the Ctrl + X dialogue.

How do I exit a nano file?

To exit nano press Ctrl+x. If there are unsaved changes, you’ll be asked whether you want to save the changes. To save the file, you must have at write permissions to the file. If you are creating a new file , you need to have write permission to the directory where the file is created.

How do I install Nano on my System?

If you don’t have nano installed on your system, you can install it using the package manager of your distribution. To open an existing file or to create a new file, type nano followed by the file name:


2 Answers

First check if there is a process editing the file.

$> jobs

You will get a list of background jobs, look for Stopped ones.

If there is and it's your editor, try re-attaching to it:

$> fg <n>

Else, if there is no running nano, make sure there is no lock-file.

ls -A *.swp

If there is, remove it.

rm nnn.swp

If you still have trouble editing the file, reboot and restart above. Maybe there are more things to try, but that's all I can think of...

like image 67
OriginalHacker Avatar answered Sep 20 '22 19:09

OriginalHacker


nano creates a lock file once you try to edit the file, I would say just try to move it and it might work.

like image 41
Iheb Abouda Avatar answered Sep 22 '22 19:09

Iheb Abouda