Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

i: Enter insert mode (before the cursor)

a: Enter insert mode (after the cursor)


o: Open a new line below the current line and enter insert mode
O: Open a new line above the current line and enter insert mode
esc: Exit insert mode or command mode and return to normal mode
:w: Save the current file
:q: Quit the editor (if no unsaved changes)
:q!: Quit the editor without saving changes
:wq: Save the file and quit the editor
dd: Delete (cut) the current line
yy: Yank (copy) the current line
p: Paste (put) the last deleted or copied text after the cursor
u: Undo the last command
Ctrl+r: Redo the last undone command
/pattern: Search forward for a pattern
?pattern: Search backward for a pattern
n: Move to the next occurrence of the search pattern
N: Move to the previous occurrence of the search pattern
:s/old/new: Replace the first occurrence of "old" with "new" in the current line
:s/old/new/g: Replace all occurrences of "old" with "new" in the current line
:%s/old/new/g: Replace all occurrences of "old" with "new" in the entire file
:%s/old/new/gc: Replace all occurrences of "old" with "new" in the entire file,
asking for confirmation
gg: Move to the first line of the file
G: Move to the last line of the file
0: Move to the beginning of the line
$: Move to the end of the line
Ctrl+f: Scroll forward one screen
Ctrl+b: Scroll backward one screen
:set number: Display line numbers
:set nonumber: Hide line numbers
:set hlsearch: Highlight search matches
:set nohlsearch: Disable search highlighting
:set ignorecase: Perform case-insensitive searches
:set smartcase: Perform case-sensitive searches if the pattern contains uppercase
letters
:set autoindent: Automatically indent new lines based on the previous line
:set expandtab: Insert spaces instead of tabs
:set tabstop=4: Set the tab width to 4 spaces
:set syntax=language: Enable syntax highlighting for a specific programming
language
:set list: Show special characters (tabs, newlines, etc.)
:set nolist: Hide special characters
:set mouse=a: Enable mouse support
:set paste: Paste text without auto-indenting or other automatic modifications
:set ruler: Display the cursor position and other information in the status line
:set background=dark: Set a dark background color scheme
:set background=light: Set a light background color scheme
:vsp: Split the window vertically
:sp: Split the window horizontally
Ctrl+w, Arrow keys: Navigate between split windows
:bn: Switch to the next buffer
:bp: Switch to the previous buffer

You might also like