GNU Nano is a lightweight yet powerful text editor for Linux, and it comes bundled in most distributions. Unlike Emacs and Vim, GNU Nano offers its users a straightforward way to quickly edit text files in the command line. This can be especially helpful if you secure a server with only an SSH terminal.
Download this Cheatsheet
Enter your email below to receive this PDF cheatsheet in your Inbox.
Essential GNU Nano Keybindings
By default, GNU Nano has a good set of keyboard shortcuts and commands you can use as soon as you load the text editor. However, one issue with this is that there is no clear way to access these shortcuts from the editor.
Knowing that, this cheatsheet gives you all the necessary keybindings for GNU Nano. Not only that, it also highlights some of the program’s little-known features.
Command | Function |
---|---|
Buffer Movement | |
Ctrl + B | Move the cursor one character backward. |
Ctrl + F | Move the cursor one character forward. |
Ctrl + P | Move the cursor one line up. |
Ctrl + N | Move the cursor one line down. |
Ctrl + Y | Move the cursor one page up. |
Ctrl + V | Move the cursor one page down. |
Ctrl + Left Arrow | Move the cursor one word backward. |
Ctrl + Right Arrow | Move the cursor one word forward. |
Ctrl + Up Arrow | Move the cursor to the previous block. |
Ctrl + Down Arrow | Move the cursor to the next block. |
Ctrl + A | Go to the beginning of the current line. |
Ctrl + E | Go to the end of the current line. |
Alt + Backslash (\) | Go to the top of the current buffer. |
Alt + Slash (/) | Go to the bottom of the current buffer. |
Alt + Less-Than (<) | Go to the previous buffer. |
Alt + Greater-Than (>) | Go to the next buffer. |
Alt + Up Arrow | Move the buffer one screen up. |
Alt + Down Arrow | Move the buffer one screen down. |
Alt + G | Go to a specific line in the buffer. |
Alt + Right Square Bracket (]) | Move the cursor to the matching bracket in the buffer. |
File Manipulation | |
Ctrl + R | Open an existing file and place it in the current buffer. |
Ctrl + S | Save the current buffer in an existing file. |
Ctrl + O | Save the current buffer as a different file. |
Ctrl + X | Close the current buffer and exit GNU Nano. |
File Editing | |
Ctrl + M | Create a new line at the current cursor position. |
Ctrl + K | Cut the current line and place it in the clipboard. |
Alt + T | Cut from the current point until the end of the buffer. |
Alt + 6 | Copy the current line and place it in the clipboard. |
Ctrl + U | Paste the clipboard in the current cursor position. |
Ctrl + H | Delete the character before the cursor. |
Ctrl + D | Delete the character beneath the cursor. |
Alt + Backspace | Delete the word to the left of the cursor. |
Ctrl + Delete | Delete the word to the right of the cursor. |
Alt + Delete | Delete the current line. |
Alt + U | Undo the last change in the buffer. |
Alt + E | Redo the last undo in the buffer. |
Ctrl + J | Justify the text in the current cursor position. |
Alt + J | Justify the text in the entire buffer. |
Alt + 3 | Comment on the currently selected lines in the buffer. |
Alt + V | Enter the next keystroke as-is in the display. |
Ctrl + Right Square Bracket (]) | Toggle GNU Nano’s autocomplete feature. |
Alt + A | Switch to Text Marking mode. |
Alt + Left Curly Bracket ({) | Indent the currently marked region. |
Alt + Right Curly Bracket (}) | Remove the indent in the currently marked region. |
Searching | |
Ctrl + W | Open the Search dialog box. |
Ctrl + Q | Open the Reverse Search dialog box. |
Alt + W | Highlight the next word that matches the search query. |
Alt + Q | Highlight the previous word that matches the search query. |
Alt + R | Open the Replace dialog box. |
Interface Manipulation | |
Ctrl + G | Display the Help screen. |
Alt + N | Display line numbers in the current buffer. |
Alt + P | Display all whitespace as printable characters. |
Alt + X | Toggle the Help Lines in the current buffer. |
Alt + B | Check for incorrect syntax in the entire buffer. |
Alt + F | Fix the formatting in the current buffer. |
Ctrl + T | Run an external command on the current buffer. |
Alt + Colon (:) | Create and save a new macro. |
Alt + Semicolon (;) | Run a macro on the current buffer. |
Ctrl + L | Reload the current GNU Nano display. |
Alt + I | Toggle GNU Nano’s Auto Indent feature. |
Alt + L | Toggle the text wrapping. |
Alt + O | Convert all typed tabs into spaces. |
Alt + M | Enable mouse support in GNU Nano. |
Image credit: Unsplash. All alterations and screenshots by Ramces Red.
Our latest tutorials delivered straight to your inbox