10

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?

tuomas-p
  • 141
  • 7

5 Answers5

7

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.

wisbucky
  • 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
2

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.

interduo
  • 401
  • 6
  • 10
2

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.

LynXz
  • 78
  • 8
1

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.

Sven Rojek
  • 5,476
  • 2
  • 35
  • 57
0

On RPI ctrl+s+ctrl+x works naturally

B Shmid
  • 1
  • 2