14 | nano editor

Linux Command Line Tutorial


When working on the command line, quite often you will need to create or edit files. Two of the most famous and powerful command-line editors are Vim and emacs. On the other hand, they are equally difficult to learn. But there is a simpler editor available to just get things done and that is nano.

All commands are prefixed with a control(^) character or metacharacter(M). caret symbol represents control and M represents Meta. Control will generally be your control key. Meta character depends on the keyboard setup. It can either be an Esc key, alt key, or a special meta key.

In this video, I will help you learn the basic usage of the nano editor, including how to create an open file, edit a file, save a file, search and replace text, cut and paste text, and more.

If you wish to get more help, while inside nano editor hit: ^G


Navigation

CommandEffect
^FForward one character
^BBack one character
^SpaceForward one word
M-SpaceBack one word
^PPrevious line
^NNext line
^ABeginning of the current line
^EEnd of the current line
M-(Beginning of the current paragraph
M-)End of the current paragraph
M-\The first line of the file
M-/The last line of the file
^_Move the cursor to a specific line
Navigation commands

Search and Replace

CommandEffect
^WSearch pattern
M-WMove to the next match
^\Search pattern and replace
Search and Replace commands

Copy, Cut and Paste

CommandEffect
M-ASelect text(set a selection mark)
^6Cancel the selection press
M-6Copy the selected text to the clipboard
^KCut the selected text
^UPaste the text at the cursor position
Copy, Cut and Paste commands

Save and Exit

CommandEffect
^OSave changes
^XExit nano
Save and Exit commands