How to save file in Nano fast

3

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?

warvariuc

Posted 2016-11-14T08:15:24.693

Reputation: 1 015

Answers

4

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!

Iskar

Posted 2016-11-14T08:15:24.693

Reputation: 266

Is there a built-in shortcut for this, so that I don't need to edit config on each server? – warvariuc – 2016-11-14T08:53:19.900

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 – 2016-11-14T08:57:53.853

0

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

rems4e

Posted 2016-11-14T08:15:24.693

Reputation: 101