Nano command editor

Nano is a text editor suited to working in a UNIX-based command line enviro­nment. It is not as powerful as PC window­-based editors, as it does not rely on the mouse, but still has many useful features.
Most nano commands are invoked by holding down the Ctrl key (that is, the control key), and pressing one of the other keys. In this text, the control key is referred to using ^. For example, ^X means “hold down the CTRL key and press the x key”. Most of the important commands are listed at the bottom of your screen when nano is running.

File Control in nano

nano index.php Open or create the file “index.php” with nano on command line.
Ctrl-o Y Enter Save changes.
Ctrl-r Alt-f Open a new file with a new buffer within nano.
Alt-> Switch to the next file buffer in nano.
Alt-< Switch to the previous file buffer in nano.
Ctrl-x Quit nano.

Navigating through file contents in nano

Ctrl-a Move to the beginning of the current line.
Ctrl-e Move to the end of the current line.
Ctrl-v Move down one page.
Ctrl-y Move up one page.
Alt-\ Go to the beginning of the file.
Alt-/ Go to the end of the file.
Alt-g Go to a target line number.
Alt-] Jump to matching open/close symbol.
Alt-a Alt-} Select a block and indent the block.
Alt-a Alt-{ Select a block and outden the block.

Copy and Paste in nano

Alt-a To select a block for copy or cut operation, do Alt-a again to unselect.
Alt-a Alt-^ Copy a highlighted block to the clipboard.
Alt-a Ctrl-k Cut a highlighted block to the clipboard.
Ctrl-k Cut from the current cursor position to the end of the current line.
Ctrl-u Paste the contents from the clipboard at the current cursor position.

Search and Replace in nano

Ctrl-w Search for a target string.
Alt-w Repeat the last search.
Alt-r Search and replace.

File Management
Key Action
Ctrl+G Display help text
Ctrl+X Close the current file buffer / Exit from nano
Ctrl+O Write the current file to disk
Ctrl+R Insert another file into the current one
Alt+> Switch to the next file buffer
Alt+< Switch to the previous file buffer
Search and Replace
Key Action
Ctrl+W Search for a string or a regular expression
Ctrl+\ Replace a string or a regular expression
Alt+W Repeat the last search
Navigation
Key Action
Ctrl+_ Go to line and column number
Ctrl+Y Go one screenful up
Ctrl+V Go one screenful down
Alt+\ Go to the first line of the file
Alt+/ Go to the last line of the file
Ctrl+B Go back one character
Ctrl+F Go forward one character
Alt+Space Go back one word
Ctrl+Space Go forward one word
Ctrl+A Go to beginning of current line
Ctrl+E Go to end of current line
Ctrl+P Go to previous line
Ctrl+N Go to next line
Alt+( Go to beginning of paragraph; then of previous paragraph
Alt+) Go just beyond end of paragraph; then of next paragraph
Alt+- Scroll up one line without scrolling the cursor
Alt++ Scroll down one line without scrolling the cursor
Alt+< Switch to the previous file buffer
Alt+> Switch to the next file buffer
Ctrl+C Display the position of the cursor
Alt+] Go to the matching bracket
Editing
Key Action
Alt+U Undo the last operation
Alt+E Redo the last undone operation
Alt+} Indent the current line
Alt+{ Unindent the current line
Alt+^ Copy the current line and store it in the cutbuffer
Ctrl+K Cut the current line and store it in the cutbuffer
Ctrl+U Uncut from the cutbuffer into the current line
Ctrl+J Justify the current paragraph
Ctrl+T Invoke the spell checker, if available
Alt+V Insert the next keystroke verbatim
Ctrl+I Insert a tab at the cursor position
Ctrl+M Insert a newline at the cursor position
Ctrl+D Delete the character under the cursor
Ctrl+H Delete the character to the left of the cursor
Alt+T Cut from the cursor position to the end of the file
Alt+J Justify the entire file
Alt+D Count the number of words, lines, and characters
Ctrl+^ Mark text starting from the cursor position
Settings
Key Action
Alt+X Help mode enable­/di­sable
Alt+C Constant cursor position display enable­/di­sable
Alt+O Use of one more line for editing enable­/di­sable
Alt+S Smooth scrolling enable­/di­sable
Alt+$ Soft wrapping of overlong lines enable­/di­sable
Alt+P Whitespace display enable­/di­sable
Alt+Y Color syntax highli­ghting enable­/di­sable
Alt+H Smart home key enable­/di­sable
Alt+I Auto indent enable­/di­sable
Alt+K Cut to end enable­/di­sable
Alt+L Hard wrapping of overlong lines enable­/di­sable
Alt+Q Conversion of typed tabs to spaces enable­/di­sable
Alt+B Backup files enable­/di­sable
Alt+F Reading file into separate buffer enable­/di­sable