Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nano - disable confirm on save?

Tags:

linux

nano

I use nano every day and I really hate when it asks every time to "save modified buffer? (yes/no)". How can I disable this?

like image 401
tuomas-p Avatar asked Oct 20 '14 08:10

tuomas-p


People also ask

How do I save a nano file without exiting?

Type y to save the file, or n to exit nano without saving the file. Closing a file also closes nano.

How do I save a buffer in nano?

Press Control+x , you will get a prompt at the bottom of the screen asking you to "Save modified buffer (Answering No will DESTROY CHANGES)". Press y as we want to save the changes, and then Enter to Save Changes and exit the nano editor.

How do I get out of nano editor?

When you use the above-mentioned key combination or the specified function key, you will be asked to save your work before exiting the Nano editor. This is highlighted in the following image. From here, you can either choose to save your work by pressing the “Y” key or exit without saving by pressing the “N” key.


2 Answers

I didn't like setting tempfile because then it also doesn't prompt you when you exit with ctrl+X. In fact, it will silently save your changes when you exit! And you can't exit without saving!

Instead, I have added this keybinding for ctrl+S to my ~/.nanorc:

bind ^S savefile main

savefile will save the file without prompting you to confirm the filename, like other editors. But if you use ctrl+X, it will prompt you if you have changes.

like image 159
wisbucky Avatar answered Sep 29 '22 02:09

wisbucky


In ~/.nanorc:

set tempfile

Also, its a good idea to add

set backup
set backupdir /home/user/.nano-backups

All files will be automatically backed up in this directory, and it is much better then confirmation.

like image 35
LynXz Avatar answered Sep 29 '22 03:09

LynXz