LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   can you search "." in vi editor by using ? or / ? (https://www.linuxquestions.org/questions/linux-newbie-8/can-you-search-in-vi-editor-by-using-or-497400/)

kachmi 10-31-2006 09:51 PM

can you search "." in vi editor by using ? or / ?
 
can you search the "." (dot) in vim editor by using ? or / ?

gilead 10-31-2006 10:39 PM

If you're looking for a dot "." you'd type /\. or ?\.- the "/" or "?" starts the search command and the "\" escapes the "." so it's treated as a literal dot.

Was that what you meant?

ayteebee 11-01-2006 06:12 AM

The dot "." is recognised by vim as being a regular expression operator, so it needs to be escaped with a backslash "\" to be read as a literal dot. It's worth finding out about regular expressions, because they're really cool and useful; having said that, it's one of those things I still need to get around to...

Bharatsoni 11-01-2006 06:15 AM

searching "." in vi
 
Hi,
for vi U can find a "." by typing /\. in the file.

reiki33 11-01-2006 10:14 AM

another useful way to delimit characters
 
Another useful technique of delimiting characters comes when you get a windows file and want to remove all of the ^M (ctrl-M) at the end of a line. You need to enter the ^M literally and not have it get taken as an end-of-line input. You can use the :%s/^v^M//g command. The ctrl-v tells vi to take the next character literally, so you can input it into the command. The s command invokes sed and will change all of the occurrences (the g part) of ^M on all (the % part) of the lines.

hufemj 11-03-2006 06:58 AM

vim and Windows
 
Quote:

Originally Posted by reiki33
Another useful technique of delimiting characters comes when you get a windows file and want to remove all of the ^M (ctrl-M) at the end of a line. You need to enter the ^M literally and not have it get taken as an end-of-line input. You can use the :%s/^v^M//g command. The ctrl-v tells vi to take the next character literally, so you can input it into the command. The s command invokes sed and will change all of the occurrences (the g part) of ^M on all (the % part) of the lines.

Okay. I know this is a Linux forum. But the thread is about vi, which I also use on Windows and which has a peculiar quirk that took me a long time to figure out. With vim on windows, the ^v is used for something else. Instead, ^q is used as the escape character.

- Mark


All times are GMT -5. The time now is 05:10 AM.