From 117d013ae984d028b8513bdb3e8b8de5492e25b8 Mon Sep 17 00:00:00 2001 From: medusa Date: Mon, 29 Apr 2024 15:22:49 +0000 Subject: [PATCH] Update docs/tech_docs/vim_reference.md --- docs/tech_docs/vim_reference.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/tech_docs/vim_reference.md b/docs/tech_docs/vim_reference.md index 56adf9e..de8c564 100644 --- a/docs/tech_docs/vim_reference.md +++ b/docs/tech_docs/vim_reference.md @@ -312,4 +312,34 @@ This reference guide provides a quick overview of the essential commands and tec --- +Certainly! Ex commands in Vim are incredibly useful for a range of text editing tasks. Here are some basic Ex commands that you should start with: +### 1. Opening and Saving Files +- **Open a file**: `:e filename` – Opens `filename` in the current buffer. +- **Write (save) the current file**: `:w` – Saves the changes you've made. +- **Save and quit**: `:wq` or `:x` – Saves changes and closes the editor. +- **Quit without saving**: `:q!` – Quits and discards any changes. + +### 2. Line Manipulation +- **Go to a specific line**: `:#` – Where `#` is the line number you want to go to. For example, `:25` takes you to line 25. +- **Move lines**: `:#m#` – Moves a line to a new position. For example, `:2m5` moves line 2 below line 5. +- **Copy lines**: `:#t#` – Copies a line to a new position. For example, `:3t5` copies line 3 below line 5. + +### 3. Searching and Replacing +- **Search for a text**: `:/pattern` – Finds the next occurrence of `pattern`. +- **Global search and replace**: `:%s/old/new/g` – Replaces all occurrences of `old` with `new` throughout the document. Remove the `g` if you only want to replace the first occurrence in each line. + +### 4. Filtering and Executing External Commands +- **Filter lines through an external command**: `:#,#!command` – For example, `:1,10!sort` sorts lines 1 to 10. +- **Read the output of an external command into the buffer**: `:r !command` – For example, `:r !date` inserts the current date into the document. + +### 5. Managing Multiple Files +- **Next file**: `:n` – Moves to the next file in the list of files opened with Vim. +- **Previous file**: `:prev` or `:p` – Moves to the previous file. + +### 6. Setting Options +- **Set options**: `:set option` – Sets different configurations. For example, `:set number` turns on line numbering, `:set nonumber` turns it off. + +### 7. Undo and Redo +- **Undo the last change**: `:undo` or just `u` in normal mode. +- **Redo the last undone change**: `:redo` or `Ctrl-r` in normal mode. \ No newline at end of file