From 180aa03dcf378a4b73b072c26215b292c3890a62 Mon Sep 17 00:00:00 2001 From: shwetha729 Date: Fri, 1 Sep 2023 08:55:43 -0400 Subject: [PATCH] Updated: Friday, September 01,2023-09-01 08:55:37 --- .../CLI Tools/CLI Tool Collection/Vim/Vim.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/enter/Coding Tips (Classical)/Terminal Tips/CLI Tools/CLI Tool Collection/Vim/Vim.md b/enter/Coding Tips (Classical)/Terminal Tips/CLI Tools/CLI Tool Collection/Vim/Vim.md index 2985cda..996a27a 100644 --- a/enter/Coding Tips (Classical)/Terminal Tips/CLI Tools/CLI Tool Collection/Vim/Vim.md +++ b/enter/Coding Tips (Classical)/Terminal Tips/CLI Tools/CLI Tool Collection/Vim/Vim.md @@ -1,7 +1,7 @@ # About Vim I was extremely surprised I didn't set up a note about my default and OG editor of choice, vim. It is what has helped long term become very fast at typing and in general for understanding the power of just using whatever editor you are most comfortable with at the end of the day. Vim is what I used when I was editing t things on a chromebook and it is still what I am using to this day. -Interact with a Vim tutorial on [Open Vim](https://www.openvim.com). Or +Interact with a Vim tutorial on [Open Vim](https://www.openvim.com). Or open up the vim `tutorial` --- @@ -13,6 +13,16 @@ There are many purposes to vim, you can use it for: - Tricks and tips from and for vim users is posted on the [wiki](https://vim.fandom.com/wiki/Vim_Tips_Wiki) - generate the config file for your vimrc for different languages no matter where you go [here](https://vim-bootstrap.com/#tagline) + +Find & Replace Text in Vim: +```vim +:[range]s/{pattern}/{string}/[flags] +``` +- What does each mean? + - `[range]` indicates that you can pass the range of lines. Pass % to find and replace in all lines. The range is separated by a comma. To find and replace between lines 5 to 10, pass 5,10. Use `.` to represent the current line and `$` the last line of the file. + - `{pattern}` indicates the pattern to find the text. You can pass regex patterns here. + - `{string}` is the string to replace in the found text.   + - `[flags]` indicates if you wish to pass any additional flags (for example, the flag `c` is passed to confirm before replacing the text). By default, this does a case-sensitive search. You can change it to do a case-insensitive search by passing a `i` flag. --- ## Copy, Cut and Paste in Normal Mode @@ -48,6 +58,11 @@ The movement commands that apply for yanking are also valid for deleting. For ex To put the yanked or deleted text, move the cursor to the desired location and press `p` to put (paste) the text after the cursor or `P` to put (paste) before the cursor. +### How to Undo or Redo in Vim + +To undo a change in Vim, press `u` in command mode. To redo, press `CTRL + R`. You can prepend a number (n) with `u` to undo `n` times. for example, `2u` will undo 2 times. To list the available undo options, type `:undolist` in command mode. + + ## Vim vs NeoVim? There's a long history and different strains of Vim on the internet. One of the more popular alternatives seems to be NeoVim