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?
Type y to save the file, or n to exit nano without saving the file. Closing a file also closes 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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With