From e033b79a65dd429a3d55fddf8e5bf3b447fd9e04 Mon Sep 17 00:00:00 2001 From: medusa Date: Mon, 6 May 2024 05:43:37 +0000 Subject: [PATCH] Update tech_docs/vim_reference.md --- tech_docs/vim_reference.md | 97 +++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/tech_docs/vim_reference.md b/tech_docs/vim_reference.md index de8c564..c73f436 100644 --- a/tech_docs/vim_reference.md +++ b/tech_docs/vim_reference.md @@ -1,4 +1,99 @@ -It's great to see the foundation of your Vim guide taking shape! Let’s 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: +Certainly! Here's a comprehensive guide to using Vim effectively, focusing on the concept of text objects and other essential features. This guide assumes basic familiarity with Vim's modes and navigation. + +1. Text Objects: + a. Word: + - `aw`: a word (includes surrounding whitespace) + - `iw`: inner word (excludes surrounding whitespace) + - Example: `daw` deletes a word and its surrounding whitespace + b. Sentence: + - `as`: a sentence + - `is`: inner sentence + - Example: `cis` changes the current sentence + c. Paragraph: + - `ap`: a paragraph + - `ip`: inner paragraph + - Example: `yap` yanks (copies) the current paragraph + d. Tag (HTML/XML): + - `at`: a tag (includes the tag itself) + - `it`: inner tag (excludes the tag) + - Example: `dat` deletes the entire tag and its contents + e. Quotes: + - `a"`, `a'`, `` a` ``: a quoted string (includes the quotes) + - `i"`, `i'`, `` i` ``: inner quoted string (excludes the quotes) + - Example: `ci"` changes the contents inside double quotes + f. Brackets: + - `a)`, `a]`, `a}`: a bracketed block (includes the brackets) + - `i)`, `i]`, `i}`: inner bracketed block (excludes the brackets) + - Example: `yi(` yanks the contents inside parentheses + g. Line: + - `al`: a line (includes indentation) + - `il`: inner line (excludes indentation) + - Example: `dal` deletes the current line and its indentation + +2. Operators: + a. `d`: delete + b. `c`: change (delete and enter insert mode) + c. `y`: yank (copy) + d. `p`: put (paste) + e. `=`: format (indent) + f. `>`: indent + g. `<`: de-indent + h. Example: `d2aw` deletes the next two words + +3. Motions: + a. `w`: move to the start of the next word + b. `e`: move to the end of the current word + c. `b`: move to the start of the previous word + d. `f/F`: find the next/previous occurrence of a character + e. `t/T`: find the character before the next/previous occurrence + f. `$`: move to the end of the line + g. `0`: move to the start of the line + h. `^`: move to the first non-blank character of the line + i. `%`: move to the matching bracket + +4. Visual Mode: + a. `v`: character-wise visual mode + b. `V`: line-wise visual mode + c. `Ctrl-v`: block-wise visual mode + d. Example: `vip` visually selects the current paragraph + +5. Search and Replace: + a. `/pattern`: search forward for the pattern + b. `?pattern`: search backward for the pattern + c. `n/N`: find the next/previous occurrence of the search pattern + d. `:%s/old/new/g`: replace all occurrences of "old" with "new" in the entire file + e. `:.,$s/old/new/g`: replace all occurrences of "old" with "new" from the current line to the end of the file + +6. Macros: + a. `qa`: start recording a macro named "a" + b. `q`: stop recording the macro + c. `@a`: execute the macro named "a" + d. `@@`: execute the last executed macro + +7. Undo and Redo: + a. `u`: undo the last change + b. `Ctrl-r`: redo the last undone change + +8. Splitting Windows: + a. `:split`: split the current window horizontally + b. `:vsplit`: split the current window vertically + c. `Ctrl-w h/j/k/l`: move to the window on the left/down/up/right + +9. Tabs: + a. `:tabnew`: open a new tab + b. `:tabn`: move to the next tab + c. `:tabp`: move to the previous tab + d. `gt`: move to the next tab + e. `gT`: move to the previous tab + +10. Other Essential Commands: + a. `:w`: save the current file + b. `:q`: quit Vim + c. `:wq` or `:x`: save and quit + d. `:q!`: quit without saving changes + e. `:help`: open Vim's help documentation + +By mastering these concepts and commands, you'll be able to navigate, manipulate, and edit text efficiently in Vim. Remember that practice is key to becoming proficient with Vim's powerful features. Don't hesitate to explore Vim's extensive documentation (`:help`) to learn even more advanced techniques and customization options. ---