Update docs/tech_docs/linux/vim.md
This commit is contained in:
@@ -1,5 +1,88 @@
|
||||
## Vim Productivity Tips and Tricks
|
||||
|
||||
### Faster File Navigation and Selection Techniques
|
||||
|
||||
1. Jumping to specific lines:
|
||||
- `:{line-number}` - Jump to a specific line number.
|
||||
- `{count}G` - Jump to a specific line number using the `G` command.
|
||||
- `{count}%` - Jump to a percentage of the file (e.g., `50%` jumps to the middle of the file).
|
||||
|
||||
2. Navigating between matching brackets:
|
||||
- `%` - Jump to the matching bracket, parenthesis, or brace.
|
||||
|
||||
3. Selecting text objects:
|
||||
- `v{motion}` - Select text based on a motion (e.g., `viw` selects the current word, `vip` selects the current paragraph).
|
||||
- `V{motion}` - Select lines based on a motion (e.g., `Vip` selects the current paragraph, including the newline).
|
||||
|
||||
4. Jumping to specific characters:
|
||||
- `f{char}` - Jump to the next occurrence of the specified character in the current line.
|
||||
- `F{char}` - Jump to the previous occurrence of the specified character in the current line.
|
||||
- `t{char}` - Jump to just before the next occurrence of the specified character in the current line.
|
||||
- `T{char}` - Jump to just after the previous occurrence of the specified character in the current line.
|
||||
|
||||
5. Navigating between changes:
|
||||
- `g;` - Jump to the previous change in the changelist.
|
||||
- `g,` - Jump to the next change in the changelist.
|
||||
|
||||
### Advanced Search and Replace Patterns
|
||||
|
||||
1. Case-sensitive search:
|
||||
- `/\C{pattern}` - Perform a case-sensitive search for the specified pattern.
|
||||
|
||||
2. Search for whole words:
|
||||
- `/\<{word}\>` - Search for the specified word as a whole word.
|
||||
|
||||
3. Search with regular expressions:
|
||||
- `/\v{regex}` - Search using regular expressions (e.g., `/\v(\d{3})-(\d{3})-(\d{4})` searches for phone numbers in the format "123-456-7890").
|
||||
|
||||
4. Replace with special characters:
|
||||
- `:%s/{pattern}/{replacement}/g` - Replace all occurrences of the pattern with the replacement text. Use `\r` for newlines, `\t` for tabs, and `\\` for backslashes in the replacement text.
|
||||
|
||||
5. Replace with captured groups:
|
||||
- `:%s/{pattern}/\1/g` - Replace all occurrences of the pattern with the first captured group. Use `\2`, `\3`, etc., for subsequent captured groups.
|
||||
|
||||
### Efficient Use of Marks and Jumps
|
||||
|
||||
1. Setting marks:
|
||||
- `m{mark}` - Set a mark at the current cursor position (e.g., `ma` sets mark "a").
|
||||
|
||||
2. Jumping to marks:
|
||||
- `'{mark}` - Jump to the line where the specified mark is located.
|
||||
- `` `{mark}`` - Jump to the exact position where the specified mark is located.
|
||||
|
||||
3. Viewing the mark list:
|
||||
- `:marks` - Display the list of marks and their locations.
|
||||
|
||||
4. Jumping between jumps:
|
||||
- `<Ctrl-o>` - Jump to the previous location in the jump list.
|
||||
- `<Ctrl-i>` - Jump to the next location in the jump list.
|
||||
|
||||
5. Viewing the jump list:
|
||||
- `:jumps` - Display the list of jumps and their locations.
|
||||
|
||||
### Leveraging Vim's Built-in Help System
|
||||
|
||||
1. Opening help:
|
||||
- `:help {topic}` - Open the help documentation for the specified topic (e.g., `:help navigation`).
|
||||
|
||||
2. Searching within help:
|
||||
- `/{pattern}` - Search for the specified pattern within the help documentation.
|
||||
|
||||
3. Following help links:
|
||||
- `<Ctrl-]>` - Follow a help link (jump to the linked topic).
|
||||
- `<Ctrl-t>` - Jump back from a followed help link.
|
||||
|
||||
4. Opening help in a split window:
|
||||
- `:vert help {topic}` - Open the help documentation in a vertical split window.
|
||||
|
||||
5. Exploring the help system:
|
||||
- `:help` - Open the main help index.
|
||||
- `:helpgrep {pattern}` - Search for the specified pattern across all help files.
|
||||
|
||||
Remember, the key to mastering these productivity tips is practice. Incorporate them into your daily Vim workflow, and they'll soon become second nature, enabling you to navigate and edit files with greater speed and efficiency.
|
||||
|
||||
## Vim Productivity Tips and Tricks
|
||||
|
||||
### Core Document Editing
|
||||
|
||||
1. Formatting paragraphs:
|
||||
|
||||
Reference in New Issue
Block a user