Use VIM Efficiently.
List of some essential Vim commands along with their descriptions:
1. Navigation:
- `h`, `j`, `k`, `l`: Move left, down, up, and right respectively.
- `gg`: Go to the first line of the file.
- `G`: Go to the last line of the file.
- `0`: Move to the beginning of the line.
- `$`: Move to the end of the line.
- `w`: Move to the beginning of the next word.
- `b`: Move to the beginning of the previous word.
2. Editing:
- `i`: Enter insert mode at the current cursor position.
- `a`: Enter insert mode after the current cursor position.
- `o`: Insert a new line below the current line and enter insert mode.
- `O`: Insert a new line above the current line and enter insert mode.
- `x`: Delete the character under the cursor.
- `dd`: Delete the current line.
- `yy`: Yank (copy) the current line.
- `p`: Paste the yanked text after the current cursor position.
- `u`: Undo the last change.
- `Ctrl + r`: Redo the last undo.
3. Saving and Quitting:
- `:w`: Save the file.
- `:q`: Quit Vim (if no changes are made).
- `:wq` or `ZZ`: Save and quit.
- `:q!`: Quit Vim without saving (force quit).
4. Search and Replace:
- `/search_term`: Search forward for 'search_term'.
- `?search_term`: Search backward for 'search_term'.
- `n`: Move to the next search result.
- `N`: Move to the previous search result.
- `:%s/old/new/g`: Replace 'old' with 'new' globally in the file.
5. Copy, Cut, and Paste (Visual mode):
- `v`: Enter visual mode to select text character by character.
- `V`: Enter visual mode to select whole lines.
- `Ctrl + v`: Enter visual block mode to select text in a block.
- `y`: Yank (copy) the selected text.
- `d`: Delete (cut) the selected text.
6. Working with Multiple Files:
- `:e filename`: Open a new file 'filename' in a new buffer.
- `:bnext` or `:bn`: Move to the next buffer.
- `:bprev` or `:bp`: Move to the previous buffer.
- `:bd`: Close the current buffer (file).
7. Miscellaneous:
- `:set number`: Display line numbers in the file.
- `:set hlsearch`: Highlight search results as you type.
- `:set ignorecase`: Ignore case while searching.
Comments
Post a Comment