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?
5 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.

- 33,218
- 10
- 150
- 101
-
This solution seems similar to the one with `set tempfile`, but setting tempfile does not work and still prompts with ctrl+o. – Timo Mar 08 '22 at 16:19
You can specify the -t flag when starting nano. From the man page:
-t (--tempfile) Always save changed buffer without prompting. Same as Pico's -t option.

- 401
- 6
- 10
In ~/.nanorc
, for nano version higher 5.0:
set saveonexit
for version below 5.0:
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.

- 78
- 8
You are looking for the tempfile setting.
If you want a permanent setting, edit your ~/.nanorc file (or create it) and add:
set tempfile
Alternatively, you can start nano with the -t
parameter.

- 5,476
- 2
- 35
- 57