Search words in vim/vi editor
To search for a word in Vim or Vi, you can use the /
key followed by the word you want to search for. For example, to search for the word "example" in a file, you would type /example
and then press Enter
.
You can also search for a word within a selection by highlighting the text you want to search and then using the *
key. For example, if you have the following text selected:
This is an example of a search.
You can search for the word "example" by pressing *
and Vim will find the next occurrence of the word "example" within the selected text.
You can also search for a word in Vim using the :s
command. For example, to search for the word "example" and replace it with the word "instance", you would type :s/example/instance/g
and then press Enter
. The g
flag at the end of the command tells Vim to perform the search and replace globally, meaning that it will replace all occurrences of the word "example" with "instance" in the file.