### Deleting - **Using Visual Mode**: - First, enter Visual mode by pressing **`v`** (for character-wise selection), **`V`** (for line-wise selection), or **`Ctrl-v`** (for block-wise selection). - Use the arrow keys or **`h`**, **`j`**, **`k`**, **`l`** to select the text you want to delete. - Once you've highlighted the desired text, press **`d`** to delete it. - **Using a Command**: - If you know the line numbers or the pattern of the text you want to delete, you can use a command. For example: - **`:10,20d`** will delete lines 10 to 20. - **`:g/pattern/d`** will delete all lines containing "pattern". - **Using Motions**: - In Normal mode, you can use motions combined with the **`d`** command to delete text. For example: - **`dw`** deletes a word. - **`d
** deletes to the end of the line. - **`dd`** deletes the entire line. ### **Copy (Yank)** - **In Visual Mode**: After selecting text, press **`y`** to copy (yank). - **Using Motions**: In Normal mode, use **`y`** followed by a motion. For example, **`yw`** copies a word, **`y
** copies to the end of the line, and **`yy`** or **`Y`** copies the whole line. - **Using Commands**: - Copying entire file with command `ggVG` - **`gg`**: Moves the cursor to the first line of the file. - **`V`**: Starts visual line mode, which allows you to select whole lines of text. - **`G`**: Moves the cursor to the last line of the file, selecting all lines between the first line and the last line. - For example, **`:10,20y`** copies lines 10 to 20 ### **Paste** - **After Cut or Copy**: Press **`p`** to paste after the cursor or **`P`** to paste before the cursor. - **Pasting a Specific Register**: If you've copied text into a specific register (e.g., **`"ayw`** to yank a word into register **`a`**), you can paste it with **`"ap`**. ### Editing Commands - To replace words use the command `:%s/<target-word>/<updated-word>/g` - **`%`**: Specifies that the substitution should happen throughout the entire file. **`%`** is a range that covers all lines in the file. - **`s`**: Indicates the substitute command. - **`sh`**: The text you want to find. - **`bash`**: The text you want to replace it with. - **`g`**: Stands for "global", which means all occurrences in the line. Without **`g`**, only the first occurrence in each line would be replaced. You optionally you can add the `i` flag to indicate the target-word can be case sensitive. ### Navigation - **To move to the start of the line:** - Press **`0`** (zero). This will take your cursor to the very beginning of the current line. - **To move to the first non-blank character of the line:** - Press **`^`**. This is useful if you want to skip leading whitespace and go directly to the start of the actual content on the line. - **To move to the end of the line:** - Press **`
**. This will take your cursor to the end of the current line. ### **Additional Tips** - **Registers**: Neovim uses registers to store cut/copied text. The default register is **`"`**, but you can use named registers (like **`"a`**) to store and retrieve text. - **System Clipboard**: To interact with the system clipboard, you might need to enable clipboard support in Neovim. This often involves setting **`clipboard=unnamed`** or **`clipboard=unnamedplus`** in your **`init.vim`** or **`init.lua`** configuration file. After this, yanking and pasting with the default commands will interact with the system clipboard. - **Undo and Redo**: Use **`u`** to undo and **`Ctrl-r`** to redo changes. - **Visual Block Mode**: With **`Ctrl-v`**, you can select and manipulate text in a columnar/block format, which is useful for editing multiple lines simultaneously.