m (How to Search for a "non-Ascii Character" moved to Search for non-ASCII characters: Page moved by JohnBot to improve title) |
(Change to TipImported template + severe manual clean) |
||
Line 1: | Line 1: | ||
{{review}} |
{{review}} |
||
+ | {{TipImported |
||
− | {{Tip |
||
|id=791 |
|id=791 |
||
+ | |previous=790 |
||
− | |title=How to Search for a "non-Ascii Character" |
||
+ | |next=792 |
||
− | |created=September 15, 2004 |
+ | |created=September 15, 2004 |
|complexity=basic |
|complexity=basic |
||
|author=zzapper |
|author=zzapper |
||
|version=5.7 |
|version=5.7 |
||
|rating=81/26 |
|rating=81/26 |
||
− | |text= |
||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
− | :h ga |
||
− | |||
− | :h c_ctrl-r |
||
− | |||
− | |||
}} |
}} |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | <pre> |
||
− | Also I noticed, I cannot even do this: %s,$,\r$, |
||
⚫ | |||
− | it always adds \n, not \r (on windows). I had to |
||
⚫ | |||
− | use gnu-EMACS to do this substitution on windows! |
||
+ | </pre> |
||
+ | ==References== |
||
− | Well such is life. |
||
+ | *{{help|ga}} |
||
+ | *{{help|c_CTRL-R}} |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | Also I noticed, I cannot even do this: %s,$,\r$, it always adds \n, not \r (on windows). I had to use gnu-EMACS to do this substitution on windows! |
||
− | perci merci |
||
− | , September 15, 2004 17:23 |
||
---- |
---- |
||
− | + | Try ^V^M (two keystrokes). |
|
− | Breadman |
||
− | , September 15, 2004 19:25 |
||
---- |
---- |
||
⚫ | |||
− | Try plugin hexman.vim |
||
− | |||
− | PeterFr--AT--aol.com |
||
− | , September 17, 2004 9:09 |
||
− | ---- |
||
− | Actually, I've found that I don't have much luck efficiently cleaning up files with vim this way. I'm certainly no expert at it; I'm sure those more skilled than I don't experience the difficulty. When working in linux, I found just using KHexEdit to do the search/replace made such cleanup jobs much quicker. There was virtually no experimentation required and as an actual hex editor, of course there wasn't any escaping required either. Overall, much faster and easier, at least for me. No such luck when I'd have to work on wintel boxes, though, so I spent a bit of time googling and found some freeware hex editors for wintel that I use the same way. Now I rarely bother using vim/gvim for this sort of non-printing character cleanup. |
||
− | |||
− | - F.J. |
||
− | |||
− | fj--AT--raremedium.net |
||
− | , October 15, 2004 11:39 |
||
− | ---- |
||
− | You know, maybe having rudimentary hex editing abilities in vim wouldn't be such a bad idea. |
||
− | |||
− | anon--AT--here.org |
||
− | , November 13, 2004 0:04 |
||
− | ---- |
||
⚫ | |||
replace all newlines by carriage returns is possible only thru xxd. |
replace all newlines by carriage returns is possible only thru xxd. |
||
− | perci merci |
||
− | , January 12, 2005 15:30 |
||
− | ---- |
||
⚫ | |||
− | |||
− | '''Anonymous''' |
||
− | , February 14, 2005 22:00 |
||
---- |
---- |
||
⚫ | |||
− | This tip worked for me perfectly !! I am using Vim from cygwin on Windows XP . |
||
− | I amusing this to replace ^M fom files. |
||
− | Thanks |
||
− | Pankaj |
||
− | pankaj--AT--sasken.com |
||
− | , March 4, 2005 22:33 |
||
---- |
---- |
||
− | <!-- parsed by vimtips.py in 0.702139 seconds--> |
Revision as of 01:34, 11 November 2007
created September 15, 2004 · complexity basic · author zzapper · version 5.7
Occasionally when you've pasted into Vim from some other application, you get a pesky visible non-ascii character. You can do a ga command to see what it is, but you might want to search for it or substitute it.
Here's a technique. Place the cursor on the character, then:
yl # yank one character into unnamed buffer /<C-R>" # pull unnamed buffer contents onto search (that's Control-R)
References
Comments
I tried this on Vim 6.3, can't yank Control-M at all.
I have to do this the regular way: /<C-q>013
Also I noticed, I cannot even do this: %s,$,\r$, it always adds \n, not \r (on windows). I had to use gnu-EMACS to do this substitution on windows!
Try ^V^M (two keystrokes).
xxd comes with vim, I use to create binary files. eg. s,\n,\r,g replace all newlines by carriage returns is possible only thru xxd.
For cleaning up win/dos text files for *nix, there's dos2unix (aka fromdos).