I edit in the vi editor. I want to search in the text for a specific phrase, e.g "Dec 1 15:13:00"
. I have tried this search string, but it's not working:
/Dec\ 1\ 15
How do I search for this string properly? Note that there may be more than one space between the parts.
Which command searches the string in file opened in vi editor? a) / or ? Explanation: The command '/' searches downward in the file and command '? ' searches upward in the file.
If you're already in vi, you can use the goto command. To do this, press Esc , type the line number, and then press Shift-g . If you press Esc and then Shift-g without specifying a line number, it will take you to the last line in the file.
Perform a basic search in Vim If you are in insert mode, simply press the 'ESC' key. To perform a basic search of the string or text that you want, move to the beginning of the file and simply press the forward-slash ( / ) key. Then type the search string and press ENTER on the keyboard to start searching.
Numbers and spaces are not special characters so
/Dec 1 15
is enough.
Generally speaking special characters are escaped with a \
. For example, if you search for Dec.
, you should type /Dec\.
If you are using Vim, you might also want to check
:help pattern.txt
And specifically the magic
chapter.
If you want to know if magic is set, type :set magic?
The magic option can change the behavior of pattern matching.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With