4

When using Nano, if I press Ctrl+O the editor will ask me to press Enter to confirm overwriting the file. This is annoying.

Is there a keyboard shortcut to save file as it is usual in other applications -- to overwrite it immediately without any additional questions?

0

2 Answers 2

7

Edit the file ~/.nanorc and add this:

bind ^S savefile main

Now ctrl+s will save your file to the same filename without prompts.

However, use this feature with caution. It will not inform you if something else has modified the file since your last save. If that's not a possible issue for you, this should work good!

2
  • Is there a built-in shortcut for this, so that I don't need to edit config on each server?
    – warvariuc
    Commented Nov 14, 2016 at 8:53
  • I do not think so. You could use the -t flag on nano to have it so your work is automatically saved when you do ctrl+x, but this is probably worse of a solution than doing an edit to your nanorc.
    – Iskar
    Commented Nov 14, 2016 at 8:57
9

Since at least Nano v3, the native Ctrl+S shortcut will directly save the file. Ctrl+O is the "Save As…" feature.

1
  • I'm at version 6.2, yet I had to use Iskars solution.
    – ccalvert
    Commented Apr 11, 2023 at 15:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .