yy: Copy the current line.3yy: Copy 3 lines.yw: Copy the current word.3yw: Copy 3 words.y$: Copy from the cursor to the end of the line.y^: Copy from the beginning of the line to the cursor.
p: Paste below the cursor.P: Paste above the cursor.
k: Move up.j: Move down.l: Move right.h: Move left.3k: Move up 3 lines.3j: Move down 3 lines.
$: Move to the end of the current line.^: Move to the beginning of the current line.H: Move to the top of the screen.M: Move to the middle of the screen.L: Move to the bottom of the screen.G: Move to the last line of the file.:1: Go to the first line.:7: Go to the 7th line.
Ctrl+f: Move one page forward.Ctrl+b: Move one page backward.
b: Move back to the beginning of the current/previous word.3b: Move back 3 words.w: Move forward to the beginning of the next word.e: Move to the end of the current word.
u: Undo the last operation.
:w: Save the file.:wq: Save and quit the editor.:q: Quit the editor.:q!: Force quit without saving changes.
:set nu: Enable line numbers.:set nonu: Disable line numbers.
:!<unix_command>: Execute any shell command.- Example:
:!date: Displays the current date.:!cal: Displays the calendar.
- Example:
To open a file and jump to a specific line:
vi +7 demo.txtThis opens demo.txt and positions the cursor on line 7.
- Nano is a command-line editor.
- It can be used to create new files and edit the content of existing files.
- It is almost like Notepad in functionality.
| Command | Function |
|---|---|
Ctrl+G / F1 |
Display this help text. |
Ctrl+X / F2 |
Close the current file buffer / Exit from nano. |
Ctrl+O / F3 |
Write the current file to disk. |
Ctrl+R / F5 |
Insert another file into the current one. |
Ctrl+W / F6 |
Search forward for a string or a regular expression. |
Ctrl+\ / M-R |
Replace a string or a regular expression. |
Ctrl+K / F9 |
Cut the current line and store it in the cutbuffer. |
Ctrl+U / F10 |
Uncut from the cutbuffer into the current line. |
Ctrl+O: Save the content to the file.Ctrl+X: Quit the editor.