How to Search in Vim

preview_player
Показать описание
Today I show you how to search in vim and how to use search and replace in vim.
👇 PULL IT DOWN FOR THE GOOD STUFF 👇

===== Follow us 🐧🐧 ======

===== Thanks to Our Patrons! ====
Tier 7 - Tux Level - Patrons
Robert M.

Tier 5 Patrons
Syd A.

Tier 4 Patrons
Devon, Patrick, Fred, Kramer K.

Tier 3 Patrons
Maeglin, Jackson Knife and Tool, Steve A, CyberGuyLinux, Garrick, Samuel

Tier 2 Patrons
Mitchel, Archsinner, Joris AKA JDawg, carnondated, Shaun, Jeremy, Odin, Martin, Andy P., Ross

Tier 1 Patrons
Marek, Camp514, Joshua Lee, Peter, Crucible, Darkbadits6, Primus, PM

#tut #vim #thelinuxcast
Рекомендации по теме
Комментарии
Автор

The tip with * and # is great! Thank you!

glsek
Автор

Hi Matt. just wanted to stop by and say congrats on 10K and I love your vim videos. You are a content generating machine! Much respect. keep it up buddy.

linuxdabbler
Автор

With search and replace (called substitute) the `/g` at the end when using `%` isn't needed. You only really use `/g` if you want to do a whole line instead of the first instance in a line. The `/G` at the end is the same as `%` and will do it globally if you forgot to at the `%` in the beginning so there's an instance of doing the same thing in multiple ways.

Another useful flag to give it is `/c` at the end as it give you "confirm mode" so you can confirm each instance you want to replace. Say it's a line with multiple instances of "so" or "because" because you like using it so much but you forgot to capitalize the beginning of a sentence each time you used it there but there are still a some instances inside sentences. You then run the command:

:s/so/So/gc

With that you will be able to confirm each instance in the line.

brainstormsurge
Автор

set ignorecase is nice, but what if you want to get the best of both worlds, use set smartcase if you use lower case it will ignore case and if you add a upper case letter then it will be search for case again

also set showmatch make the cursor jump to the first match making easy to see if you are searching for the right thing, it beep if nothing is found

zeocamo
Автор

n vs N, because "*" searches forward and "#" searches backwards, that's why n <> N are ""reversed". Same for "/" and "?".

nbensa
Автор

Great video Matt. I find for older system sublime text is much snappier and can do the same job for the most part.

damolin
Автор

Do you know a way to highlit multiple search patterns in different colors
Eg /\vgreen|blue|red
If you could do a video on that would be great. thanks

manojadikari
Автор

Is search and replace basically just sed? kinda looks like it.

CassyMorlock
Автор

The reason why "n" and "N" is reversed in reverse search is, is easy. Because "n" is the next search result that you asked to look in reverse. It makes sense. Because if you search in reverse, then most likely you want go back a few steps backwards. And the easiest key is n and not N.
From logical standpoint, this makes sense. However, it might be unintuitive for you. It got me off guard too in the beginning. And in worse case you can still make remaps.

BTW for reverse search I use "?" question mark. Not sure if that is the default.

thingsiplay
Автор

What color scheme are you using in your terminal Matt?

ARose
Автор

Useful video. One thing is clear to me. VIM is not for me

sandeepvk
Автор

Other than The Primagen, there are no actual proficient users. ;)

AndrewErwin
Автор

Got one for you, how to CAT an encrypted vim text file.

hunhau
Автор

when you make a back search then you are search for a word the is up in the document, so if the first result is not the one you of cuz use n to get the next in the backward dir.
and if you want to back trace then it N for that, this way it work the same for forward and backward search..

tl;dr: it is a feature and not a bug :)

zeocamo
Автор

if you don't mind sharing, what's your day job ?

hectorcanizales
Автор

I wanted to like the video but i just couldn't so let this comment be my like

lucashandekyn
Автор

finally I know how to remove those damned highlights 😄😄

alexsnowblind