nano
text processingLinux/Unix
The nano command is one of the most frequently used commands in Linux/Unix-like operating systems. nano A simple command-line text editor
Quick Reference
Command Name:
nano
Category:
text processing
Platform:
Linux/Unix
Basic Usage:
nano [options] [arguments]
Common Use Cases
Syntax
nano [options] [[+line[,column]] file]...
Options
Option | Description |
---|---|
-A , --smarthome |
Enable smart home key |
-B , --backup |
Save backups of existing files |
-C directory , --backupdir=directory |
Directory for saving unique backup files |
-D , --boldtext |
Use bold text instead of reverse video |
-E , --tabstospaces |
Convert typed tabs to spaces |
-F , --multibuffer |
Enable multiple file buffers (if available) |
-G , --locking |
Use file locking if available |
-H , --historylog |
Log & read search/replace string history |
-I , --ignorercfiles |
Don't look at nanorc files |
-J # , --guidestripe=# |
Show a guide bar at specified column |
-K , --rawsequences |
Fix numeric keypad key confusion problem |
-L , --nonewlines |
Don't add newlines to the ends of files |
-M , --trimblanks |
Trim trailing spaces when hardwrapping |
-N , --noconvert |
Don't convert files from DOS/Mac format |
-O , --morespace |
Use more space at the bottom of the screen |
-P , --positionlog |
Log & read location of cursor position |
-Q "str" , --quotestr="str" |
String to use for quoting |
-R , --restricted |
Restricted mode (can't read/write outside current dir) |
-S , --smooth |
Smooth scrolling |
-T # , --tabsize=# |
Set width of a tab to # columns |
-U , --quickblank |
Do quick status-bar blanking |
-V , --version |
Print version information and exit |
-W , --wordbounds |
Detect word boundaries more accurately |
-X "str" , --wordchars="str" |
Characters that are part of a word |
-Y name , --syntax=name |
Syntax definition to use for coloring |
-Z , --zap |
Let Bsp and Del erase a marked region |
-a , --atblanks |
When soft-wrapping, do it at whitespace |
-b , --breaklonglines |
Automatically hard-wrap overlong lines |
-c , --constantshow |
Constantly show cursor position |
-d , --rebinddelete |
Fix Backspace/Delete confusion problem |
-e , --emptyline |
Keep the line below the title bar empty |
-f file , --rcfile=file |
Use only this file for configuring nano |
-g , --showcursor |
Show cursor in file browser & help text |
-h , --help |
Show help text and exit |
-i , --autoindent |
Automatically indent new lines |
-j , --jumpyscrolling |
Scroll by half-screen, not by line |
-k , --cutfromcursor |
Cut from cursor to end of line |
-l , --linenumbers |
Show line numbers in front of the text |
-m , --mouse |
Enable the use of the mouse |
-n , --noread |
Do not read the file (only write it) |
-o directory , --operatingdir=directory |
Set operating directory |
-p , --preserve |
Preserve XON (^Q) and XOFF (^S) keys |
-q , --quiet |
Silence startup warnings |
-r # , --fill=# |
Set hard-wrap line length to # columns |
-s program , --speller=program |
Use this program to check spelling |
-t , --saveonexit |
Save changes on exit, don't prompt |
-u , --unix |
Save a file by default in Unix format |
-v , --view |
View mode (read-only) |
-w , --nowrap |
Don't hard-wrap long lines |
-x , --nohelp |
Don't show the two help lines |
-y , --afterends |
Make Ctrl+Right stop at word ends |
-z , --suspend |
Enable suspension |
-$ , --softwrap |
Enable soft line wrapping |
Commonly Used Keyboard Commands:
Key Combination | Action |
---|---|
Ctrl+G |
Display help text |
Ctrl+O |
Save current file |
Ctrl+X |
Exit nano |
Ctrl+K |
Cut current line (or marked text) |
Ctrl+U |
Paste text from the cut buffer |
Ctrl+W |
Search for text |
Ctrl+\ |
Search and replace text |
Ctrl+A |
Move to beginning of current line |
Ctrl+E |
Move to end of current line |
Ctrl+Y |
Move to previous screen |
Ctrl+V |
Move to next screen |
Ctrl+_ |
Go to specific line number |
Alt+A |
Mark text starting from cursor position |
Alt+6 |
Copy current line (or marked text) |
Ctrl+C |
Show cursor position |
Ctrl+T |
Invoke the spell checker, if available |
Ctrl+R |
Insert contents of another file into current buffer |
Ctrl+J |
Justify the current paragraph |
Alt+J |
Justify the entire file |
Examples
How to Use These Examples
The examples below show common ways to use the nano
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
nano file.txt