When it comes to editing text in Nano, I find these keyboard shortcuts are of great benefit:
- Alt+M - Enable/Disable mouse support mode.
- Ctrl+6- Switch on marking (mark set/unset)
- Ctrl+A- Move to beginning of current line.
- Ctrl+K- This shortcut has magical dual functionalities, it cuts (deletes) the whole line of selection when mouse support mode is disabled, and it cuts (deletes) the whole selected word/text when mouse support mode is enabled.
- Ctrl+D- Delete the character under the cursor
- Ctrl+H- Delete the character to the left of the cursor
- Ctrl+U- Uncut from the cutbuffer into the current line.
- Ctrl+space- Move forward one word. When mose support mode is enabled, it will select the words one by one with every hit on the keys.
If you would like to make edits at/to a specific word in the text, then you need to do the following:
- Hit Alt+M to enable "mouse support mode".
- Double click on the word of choice and this will switch on marking (mark set/unset). When you click on the word of choice and marking is set on, then select the word or the text of choice using the mouse (exactly like how you usually select text in any word editor e.g. gedit). Or, alternatively you can hit Ctrl+6 to enable marking, then Ctrl+space to select the word/text that you would like to edit.
- Use Ctrl+H to delete the characters of that selected word, or alternatively use Ctrl+K to cut (delete) the selected word/text when mouse support mode is enabled.
In order to undo/redo actions, nano has experimental undo/redo feature. In nano manual:
$man nano
. . . .
-u (--undo)
Enable experimental generic-purpose undo code. By default, the undo and redo shortcuts are Meta-U and Meta-E, respectively.
. . . .
To activate "undo/redo" mode, you’ll need to start nano with the -u option:
$ nano -u file.txt
… and then you can use Alt+U to undo and Alt+E to redo.
More details about the Nano's keyboard shortcuts