Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search for a character the displays as "<85>" in Vim

I have a file that was converted from EBCDIC to ASCII. Where there used to be new lines there are now characters that show up as <85> (a symbol representing a single character, not the four characters it appears to be) and the whole file is on one line. I want to search for them and replace them all with new lines again, but I don't know how.

I tried putting the cursor over one and using * to search for the next occurrence, hoping that it might show up in my / search history. That didn't work, it just searched for the word that followed the <85> character.

I searched Google, but didn't see anything obvious.

My goal is to build a search and replace string like:

:%s/<85>/\n/g   

Which currently just gives me:

E486: Pattern not found: <85>  
like image 924
Thomas G Henry Avatar asked Jan 18 '10 15:01

Thomas G Henry


People also ask

How do I find special characters in Vim?

^ * $ \ ? ) have special significance to the search process and must be “escaped” when they are used in a search. To escape a special character, precede it with a backslash ( \ ). For example, to search for the string “anything?” type /anything\? and press Return.

How do I search for text in vim?

One can search forward in vim/vi by pressing / and then typing your search pattern/word. To search backward in vi/vim by pressing ? and then typing your search pattern/word. Once word found in vim, you can press the n key to go directly to the next occurrence of the word in backwards.

How do I search for a specific string in Gvim?

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.

How do I search last of file?

View Recent Files Using Windows Search If you want to see all the recent files on your system, Windows Search is the answer. Start by opening File Explorer to the top level folder you want to search. For example, selecting your Documents folder searches everything in that folder and all the subfolders it contains.


1 Answers

I found "Find & Replace non-printable characters in vim" searching Google. It seems like you should be able to do:

:%s/\%x85/\r/gc

Omit the c to do the replacement without prompting, try with c first to make sure it is doing what you want it to do.

In Vim, typing :h \%x gives more details. In addition to \%x, you can use \%d, \%o, \%u and \%U for decimal, octal, up to four and up to eight hexadecimal characters.

like image 196
Alok Singhal Avatar answered Sep 22 '22 08:09

Alok Singhal