Linux Vi Searching - Javatpoint
Có thể bạn quan tâm
In command mode, with the help of '/' , string can be searched in forward direction and with the help of ? , string can be searched in backward direction. For example, /abc will do a forward search for string abc whereas ?abc will do a backward search for string abc.
/string
Here string has to be replaced by the searching word.
The /string allows us to do forward search for a string. If the same string is placed before and after the cursor, it will only indicate the string after the cursor. When you'll start typing /string in command mode, at lower left corner, typed word will be seen.
Example:
/readable
Look at the above snapshot, this is our normal script. We have to search word readable from this script.
Look at the above snapshot, after typing /readable and pressing enter, mentioned word on its first occurence will be automatically highlighted. Please note here, first occurence is in forward search. The string readable is also present before the cursor, but it searches forward.
?string
The ?string allows us to do backward search for a string. If the same string is placed before and after the cursor, it will only indicate the string before the cursor. When you'll start typing ?string in command mode, at lower left corner, typed word will be seen.
Example:
/readable
Look at the above snapshot, this is our normal script. We have to search word readable from this script.
Look at the above snapshot, after typing ?readable and pressing enter, mentioned word on its first occurence will be automatically highlighted. Please note here, first occurence is in backward search. The string readable is also present after the cursor, but it searches backward.
/^string
This command searches a string in forward direction but at the beginning of a line. If no such word is present at the beginning of the line, it will show a no match message.
Example:
/^readable
Look at the above snapshot, after typing /^readable, cursor moved to the string which is at the starting of the line.
/string$
This command searches string in forward direction but at the end of a line. If no such word is present at the end of the line, it will show a no match message.
Example:
/readable$
Look at the above snapshot, after typing /readable$, cursor moved to the string which is at the end of the line.
n
The n command indicates the next occurence of the searched string.
Look at the above snapshot, cursor is at first occurence of string.
Look at the above snapshot, after pressing n, cursor is at next occurence of the string.
/\
This command only searches for specifically the word enclosed in <>.
Example 1:
/\
Look at the above snapshot, after typing /\<he\> command, we got the word he.
Example 2:
/he
Look at the above snapshot, after searching for he with command /he, cursor has highlighted he from the word.
/pl[abc]ce
This command is helpful when you are in doubt with the spelling of a word. Here you can write all the possibilities related to your search.
Example:
/cont[ae]nt
Look at the above snapshot, after typing command /cont[ae]nt, word content is highlighted.Next TopicLinux vi Replace all← prev next →Từ khóa » Vi In Linux Search
-
Searching And Replacing With Vi
-
How To Search In Vim / Vi - Linuxize
-
How To Find A Word In Vim Or Vi Text Editor - NixCraft
-
How To Search To Find A Word In Vim Or Vi Text Editor - PhoenixNAP
-
Search In Vim Editor: Linux, For Words
-
How To Search In Vim / Vi - TecAdmin
-
How To Search In Vim/Vi? - LinuxTect
-
How To Search In Vim - Linux Hint
-
How To Search In VI Editor - Fedingo
-
How To Search And Replace In Vi - Qualitest
-
How To Search In VIM/VI Editor? [VI/VIM Search] - MonoVM
-
Searching And Replacing In Vi
-
08 Vim Tutorial - How To Search In Vi Editor - YouTube
-
How To Search Using Vi Linux?