💾 Archived View for squid.flounder.online › cheatsheet › nano.gmi captured on 2024-08-31 at 11:40:44. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-06-04)

-=-=-=-=-=-=-

Return to Squid's World

Return to Squid's Cheat Sheets

Nano Cheat Sheet

Changing the View

Show Line Numbers

ALT + N

CTRL + 3 then SHIFT 3

Both options work but ALT + N is easier <.<

Word-wrapping ("soft mode" aka "normal" mode)

ALT + SHIFT + 4

Visible White Space

ALT + P

Hide / Show the Help Lines

ALT + X

Current File

Save the file

CTRL + S

Save as...

CTRL + O

Exit file

CTRL + X

Searching within the file

CTRL + W (forward)

CTRL + Q (backward)

(helpful mnemonic: "CTRL + Where..?")

Find next occurrence (of previous search)

ALT + W (forward)

ALT + Q (backward)

"Find and Replace"

ALT + R

Navigation

Move the cursor

General Movement

UP, DOWN, LEFT, RIGHT

HOME, END, PAGE UP, PAGE DOWN

Move one word at at a time

CTRL + RIGHT

CTRL + LEFT

Move one "block" at a time

CTRL + UP

CTRL + DOWN

A "block" is a series of non-empty lines.

Jump to opening / closing bracket

ALT + ]

This is useful for coding - if you have an open or close bracket, you can place the cursor on that bracket and then use this keyboard shortcut to find the corresponding bracket.

Go To Line

ALT + G

CTRL + _

ALT + G is easier <.<

Show Current Line and Column #

CTRL + C

Move the *viewport* (without moving the cursor)

ALT + UP

ALT + DOWN

Go to Beginning

ALT + \

Go to End

ALT + /

Selecting, Copying, Cutting, and Pasting Text

Selecting text with the "Mark"

ALT + A

This toggles the selection. Now you can use the standard navigation keys to move the cursor. The text between the beginning location of the cursor and the current location of the cursor will be highlighted (selected)

Selecting text with "SHIFT"

If you hold "Shift" while moving the cursor, it will highlight the text you are moving over.

Select the next character

SHIFT + LEFT

SHIFT + RIGHT

Select/unselect one word at a time

CTRL + SHIFT + RIGHT

CTRL + SHIFT + LEFT

Select/unselect one block at a time

CTRL + SHIFT + UP

CTRL + SHIFT + DOWN

Some notes on Selecting Text

When you mark/select text in nano, it doesn't select the first character of the block or word when you are moving by block/word. I've developed a habit of holding SHIFT but releasing CTRL, then move one more character to get it just right.

Copying Text

ALT + 6

Cutting Text

CTRL + K

Pasting Text

CTRL + U

Some notes on Copying/Pasting Text

If you use the copy or cut keybind, then the current line will be copied or cut. If you have text selected, then the selected text will be cut. Pasting will take place at the current cursor position.

Commonly Needed Configurations

create the file ~/.nanorc

To use any of the rules below, just add the line to the .nanorc file

To set tabsize:

set tabsize 4

The above example is a 4 space tab suitable for python

To set tabs to spaces

set tabstospaces

this line is necessary to make nano treat tabs as spaces instead of tabs. This is also necessary for python

To always show line numbers by default

set linenumbers

This line helps with coding and debugging.