Nano Cheatsheet
Überblick
GNU nano ist ein einfacher, benutzerfreundlicher Texteditor für Unix- und Linux-Systeme. Es ist einfach zu bedienen und bietet eine gute Alternative zu komplexeren Editoren wie Vim oder Emacs.
Basisnutzung
Starting Nano
# Open nano
nano
# Open specific file
nano filename.txt
# Open file at specific line
nano +10 filename.txt
# Open file in read-only mode
nano -v filename.txt
# Open with line numbers
nano -l filename.txt
# Open with syntax highlighting
nano -Y python script.py
```_
### Kommandozeilenoptionen
```bash
-A, --smarthome # Enable smart home key
-B, --backup # Save backups of existing files
-C, --backupdir=DIR # Directory for saving backup files
-D, --boldtext # Use bold text instead of reverse video
-E, --tabstospaces # Convert typed tabs to spaces
-F, --multibuffer # Enable multiple file buffers
-G, --locking # Use vim-style file locking
-H, --historylog # Log search and replace strings
-I, --ignorercfiles # Don't look at nanorc files
-J, --guidestripe=NUM # Show guide stripe at column NUM
-K, --rawsequences # Fix numeric keypad key confusion
-L, --nonewlines # Don't add newlines to file ends
-M, --trimblanks # Trim trailing whitespace when saving
-N, --noconvert # Don't convert files from DOS/Mac format
-O, --morespace # Use one more line for editing
-P, --positionlog # Log and read location of cursor position
-Q, --quotestr=STR # Quoting string for email-style quoting
-R, --restricted # Restricted mode
-S, --smooth # Smooth scrolling
-T, --tabsize=NUM # Set width of a tab to NUM columns
-U, --quickblank # Do quick statusbar blanking
-V, --version # Print version information and exit
-W, --wordbounds # Detect word boundaries more accurately
-X, --wordchars=STR # Which characters are word parts
-Y, --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, --rcfile=FILE # Use only this file for configuring nano
-g, --showcursor # Show cursor in file browser
-h, --help # Show help message and exit
-i, --autoindent # Automatically indent new lines
-j, --jumpyscrolling # Scroll by half-screens, not by lines
-k, --cutfromcursor # Cut from cursor to end of line
-l, --linenumbers # Show line numbers in front of the text
-m, --mouse # Enable mouse support
-n, --noread # Do not read the file (only write it)
-o, --operatingdir=DIR # Set operating directory
-p, --preserve # Preserve XON (^Q) and XOFF (^S) keys
-q, --indicator # Show a position+portion indicator
-r, --fill=NUM # Set hard-wrap point at column NUM
-s, --speller=PROG # Enable alternate speller
-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
```_
## Navigation
### Grundbewegung
Arrow keys # Move cursor Ctrl+A # Go to beginning of line Ctrl+E # Go to end of line Ctrl+Y # Go to previous page Ctrl+V # Go to next page Ctrl+_ # Go to line and column number Alt+G # Go to line number Alt+] # Go to matching bracket
### Erweiterte Navigation
Ctrl+P # Previous line Ctrl+N # Next line Ctrl+F # Forward one character Ctrl+B # Backward one character Alt+Space # Forward one word Ctrl+Space # Backward one word Alt+( # Go to beginning of paragraph Alt+) # Go to end of paragraph
## Bearbeitung
### Grundbearbeitung
Ctrl+K # Cut current line Ctrl+U # Paste (uncut) Ctrl+6 # Mark text (start selection) Alt+6 # Copy marked text Ctrl+K # Cut marked text Alt+U # Undo last operation Alt+E # Redo last undone operation Ctrl+D # Delete character under cursor Ctrl+H # Delete character before cursor
### Erweiterte Bearbeitung
Alt+3 # Comment/uncomment line Alt+\\} # Indent marked text Alt+\\{ # Unindent marked text Ctrl+T # Execute command Alt+T # Cut from cursor to end of file Alt+J # Justify paragraph Alt+B # Backward search Alt+W # Forward search Ctrl+\ # Replace text
## Suchen und Ersetzen
### Suche
Ctrl+W # Search (Where is) Alt+W # Search next occurrence Alt+Q # Search previous occurrence Ctrl+Q # Start backward search
### Ersatz
Ctrl+\ # Search and replace Alt+R # Replace in selection
### Suchoptionen
M-C # Case sensitive search M-R # Regular expression search M-B # Backward search M-W # Whole word search
## Dateioperationen
### Dateiverwaltung
Ctrl+O # Write out (save) file Ctrl+R # Read file (insert file) Ctrl+X # Exit nano Ctrl+G # Get help Ctrl+C # Show cursor position
### Mehrere Dateien
Alt+< # Switch to previous file Alt+> # Switch to next file Ctrl+T # To Files (file browser)
## Auswahl und Kopieren
### Textauswahl
Ctrl+6 # Start marking text Alt+A # Mark all text Ctrl+K # Cut marked text Alt+6 # Copy marked text without cutting Ctrl+U # Paste text
### Erweiterte Auswahl
Alt+Shift+Arrow # Select text with arrow keys Ctrl+6 + movement # Mark text while moving
## Konfiguration
### Konfigurationsdatei (.nanorc)
```bash
# Create/edit configuration file
nano ~/.nanorc
# System-wide configuration
/etc/nanorc
```_
### Gemeinsame Konfigurationsoptionen
```bash
# Show line numbers
set linenumbers
# Enable mouse support
set mouse
# Set tab size
set tabsize 4
# Convert tabs to spaces
set tabstospaces
# Enable auto-indentation
set autoindent
# Enable soft wrapping
set softwrap
# Show whitespace
set whitespace
# Enable syntax highlighting
include "/usr/share/nano/*.nanorc"
# Set backup directory
set backupdir "~/.nano/backups"
# Enable backups
set backup
# Smooth scrolling
set smooth
# Show cursor position
set constantshow
# Enable suspension with Ctrl+Z
set suspend
# Trim trailing whitespace
set trimblanks
# Use bold text
set boldtext
# Show guide stripe at column 80
set guidestripe 80
```_
### Syntax Highlights
```bash
# Enable syntax highlighting for specific file types
syntax "python" "\.py$"
| color blue "def | class | import | from " |
color red "".*""
color green "#.*$"
# Include all available syntax files
include "/usr/share/nano/*.nanorc"
# Custom syntax highlighting
syntax "myconfig" "\.conf$|\.config$"
color red "^[[:space:]]*[^=]*="
color blue "=.*$"
color green "^[[:space:]]*#.*$"
```_
## Schlüsselbindungen
### Default Schlüsselbindungen
^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^X Exit ^R Read File ^\ Replace ^U Paste Text ^J Justify ^T To Spell ^C Cur Pos ^_ Go To Line
### Kundenspezifische Schlüsselbindungen
```bash
# In .nanorc file
bind ^S savefile main
bind ^Q exit main
bind ^F whereis main
bind ^H help main
bind M-U undo main
bind M-R redo main
```_
## Spell Checking
### Eingebauter Spell Checker
Ctrl+T # Invoke spell checker
### Externer Spell Checker
```bash
# Use aspell
nano -s aspell filename.txt
# Use ispell
nano -s ispell filename.txt
# Configure in .nanorc
set speller "aspell -x -c"
```_
## Mehrere Buffers
### Buffer Management
Alt+< # Previous buffer Alt+> # Next buffer Ctrl+T # File browser
### Mehrere Dateien öffnen
```bash
# Open multiple files
nano file1.txt file2.txt file3.txt
# Enable multibuffer mode
nano -F file1.txt file2.txt
```_
## Erweiterte Funktionen
### Reguläre Ausdrücke
```bash
# Enable regex in search/replace
Alt+R (during search)
# Common regex patterns
. # Any character
* # Zero or more of preceding
+ # One or more of preceding
? # Zero or one of preceding
^ # Beginning of line
$ # End of line
[abc] # Any of a, b, or c
[^abc] # Not a, b, or c
\d # Digit
\w # Word character
\s # Whitespace
```_
### Macros
```bash
# Nano doesn't have built-in macros, but you can:
# 1. Use external tools
# 2. Create shell scripts
# 3. Use sed/awk for repetitive tasks
```_
### Backup und Recovery
```bash
# Enable backups in .nanorc
set backup
set backupdir "~/.nano/backups"
# Backup files are created with ~ suffix
# Original: file.txt
# Backup: file.txt~
```_
## Tipps und Tricks
### Produktivität Tipps
Ctrl+A, Ctrl+K # Cut entire line quickly Ctrl+6, Ctrl+E, Alt+6 # Copy entire line Alt+3 # Comment/uncomment (if configured) Ctrl+W, Ctrl+R # Search and replace workflow Ctrl+C # Check cursor position and file stats
### Nützliche Kombinationen
```bash
# Quick save and exit
Ctrl+O, Enter, Ctrl+X
# Select all and copy
Alt+A, Alt+6
# Go to specific line
Ctrl+_, line_number, Enter
# Search for text and replace
Ctrl+W, search_term, Enter, Ctrl+\, replacement, Enter
```_
### Arbeiten mit großen Dateien
```bash
# Open large files efficiently
nano -v largefile.txt # Read-only mode
# Use line numbers for navigation
nano -l largefile.txt
# Jump to specific line
nano +1000 largefile.txt
```_
## Fehlerbehebung
### Gemeinsame Themen
```bash
# Terminal issues
export TERM=xterm-256color
# Key binding conflicts
# Check terminal settings
stty -a
# Permission issues
sudo nano /etc/hosts
# Encoding issues
nano -T 4 file.txt # Set tab width
```_
### Erholung
```bash
# Recover unsaved changes
# Nano creates .save files for unsaved work
ls -la *.save
# Restore from backup
cp file.txt~ file.txt
```_
## Vergleich mit anderen Editoren
### Nano vs Vim
Nano: + Easy to learn + Intuitive key bindings + Good for beginners - Limited advanced features - Less efficient for complex editing
Vim: + Powerful editing capabilities + Highly customizable + Modal editing - Steep learning curve - Complex key bindings
### Nano gegen Emacs
Nano: + Simple and lightweight + Quick startup + Easy configuration - Limited extensibility - Fewer features
Emacs: + Highly extensible + Rich feature set + Powerful customization - Complex interface - Resource intensive ```_
Ressourcen
- *Offizielle Dokumentation: nano-editor.org
- Manuelle Seite*:
man nano
_ - Help*:
nano --help
oderCtrl+G
in Nano - *Konfigurationsbeispiele:
/usr/share/doc/nano/examples/
_