Update docs/tech_docs/vim_reference.md

This commit is contained in:
2024-04-19 01:16:06 +00:00
parent 15606ee01f
commit 148c2ac9aa

View File

@@ -1,3 +1,106 @@
It's great to see the foundation of your Vim guide taking shape! Lets review and enrich the content with some more context and practical examples, especially focusing on programming and working with structured data. Here's a refined and expanded version based on your feedback and previous content:
---
# Vim Guide
## 1. Introduction to Vim's Philosophy
Vim, renowned for its modal editing system, allows users to switch between various modes designed for specific tasks such as inserting text, navigating within files, or executing commands. This modal approach greatly enhances editing efficiency by reducing the number of keystrokes required for tasks and enabling a more intuitive control over text manipulation.
## 2. Quick Reference Guide
This section provides a quick lookup for the most frequently used Vim commands, categorized for easy reference:
- **Navigating**
- `h, j, k, l`: Move left, down, up, right (the arrow keys of Vim).
- `gg, G`: Jump to the top or bottom of the document.
- **Editing**
- `i, a, o`: Enter insert mode at cursor, after cursor, or on a new line.
- `d, c, y`: Delete, change, or yank (copy) text.
- **Searching**
- `/pattern, ?pattern`: Search forward or backward for a pattern.
- `n, N`: Repeat search in the same or opposite direction.
## 3. Core Guides with Integrated Efficiency Tips
### Basic Editing and File Management
**Opening, Saving, and Exiting Files**
- **Commands**: `vim filename`, `:w`, `:wq`, `:q!`
- **Description**: Open files with `vim filename`. Save with `:w`, exit with `:q!`, or combine both with `:wq`.
- **Tip**: Use `ZZ` as a quicker alternative to `:wq` when you need to save and exit efficiently.
**Navigating Within Files**
- **Commands**: `h, j, k, l`
- **Description**: Precisely navigate within lines or across the text.
- **Tip**: Pair `h, j, k, l` with `Ctrl` (e.g., `Ctrl-f` and `Ctrl-b`) for faster document scrolling.
### Efficient Navigation
**Word and Line Movements**
- **Commands**: `w, b, e, 0, ^, $`
- **Description**: Navigate efficiently by words or to specific positions within a line.
- **Tip**: `5w` can save significant time by jumping five words forward, reducing repeated keystrokes.
**Document Navigation**
- **Commands**: `gg, G`
- **Description**: Quickly move to the beginning or end of a document, or directly to a specific line with `50G`.
- **Tip**: Use percentage jumps like `50%` to reach the midpoint of a document quickly.
### Advanced Text Manipulation
**Editing Commands**
- **Commands**: `dw, ciw, d$`
- **Description**: Efficient commands for deleting a word, changing inside a word, or deleting to the end of a line.
- **Tip**: `ci(` changes content inside parentheses, a common task in programming.
**Using Visual Mode for Complex Selections**
- **Commands**: `v, V, Ctrl-v`
- **Description**: Select text for manipulation in various modes: character, line, or block.
- **Tip**: Use `>` or `<` to indent selected blocks quickly, crucial in code formatting.
### Search and Replace
**Finding and Replacing Text**
- **Commands**: `:s/old/new/g`, `/%s/old/new/g`
- **Description**: Replace 'old' text with 'new' globally or within the current line.
- **Tip**: Use `*` to search for the word under the cursor quickly.
**Navigational Searches**
- **Commands**: `f<char>, F<char>, t<char>, T<char>`
- **Description**: Jump to the next or previous occurrence of a character on the line.
- **Tip**: Use `;` and `,` to repeat the last `f` or `t` search efficiently.
### Enhanced Motion for Programming and Structured Data
**Paragraph and Section Motions**
- **Commands**: `{`, `}`, `[[`, `]]`
- **Description**: Navigate quickly between paragraphs or code blocks. Ideal for structured data and code structures.
**Screen Motions**
- **Commands**: `H`, `M`, `L`, `Ctrl-d`, `Ctrl-u`
- **Description**: Manage on-screen text positioning and rapid scrolling effectively.
**Document Motions**
- **Commands**: `gg`, `G`
- **Description**: Essential for moving quickly through large files or to specific lines, critical in debugging and reviewing.
### Tips for Using Motions in Structured Data and Programming
- Combine motions with searches for efficient navigation within XML, JSON
, or YAML, especially useful in large data files or complex codebases.
- Record macros for repetitive edits across similar structures, optimizing time and ensuring consistency.
- Utilize `Ctrl-v` for block visual mode, particularly effective for column-based editing or configuration adjustments.
---
This expanded guide not only provides a comprehensive look at using Vim effectively but also integrates practical tips directly applicable to programming and structured data editing, ensuring users can leverage Vim's power to its fullest.
---
```markdown
Here's a streamlined outline of the VIM guides, focusing on the most relevant and commonly used topics:
I. Copy, Paste, and Find/Replace Operations
@@ -67,6 +170,7 @@ IX. Customizing VIM with .vimrc
B. Basic .vimrc Settings
C. Mapping Keys in .vimrc
D. Customizing VIM Plugins in .vimrc
```
This streamlined outline focuses on the most essential and commonly used features of VIM that are relevant to a majority of users. It covers copy/paste operations, useful tasks, visual mode, text objects and motions, undo/redo, buffer management, marks and jumps, registers, and basic customization with .vimrc.