m (How to Search for a "non-Ascii Character" moved to Search for non-ASCII characters: Page moved by JohnBot to improve title) |
(Change <tt> to <code>, perhaps also minor tweak.) |
||
(7 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{TipImported |
||
− | {{review}} |
||
− | {{Tip |
||
|id=791 |
|id=791 |
||
+ | |previous=790 |
||
− | |title=How to Search for a "non-Ascii Character" |
||
+ | |next=792 |
||
− | |created= |
+ | |created=2004 |
|complexity=basic |
|complexity=basic |
||
|author=zzapper |
|author=zzapper |
||
|version=5.7 |
|version=5.7 |
||
|rating=81/26 |
|rating=81/26 |
||
+ | |category1=Usage |
||
− | |text= |
||
+ | |category2= |
||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
− | :h ga |
||
− | |||
− | :h c_ctrl-r |
||
− | |||
− | |||
}} |
}} |
||
⚫ | |||
⚫ | |||
⚫ | |||
− | I tried this on VIM6.3, can't yank Control-M at all. |
||
− | I have to do this the regular way: /<C-q>013 |
||
+ | <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}} |
||
− | |||
− | |||
− | |||
− | perci merci |
||
− | , September 15, 2004 17:23 |
||
− | ---- |
||
⚫ | |||
− | |||
− | 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 |
||
− | ---- |
||
− | 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. |
||
⚫ | |||
− | perci merci |
||
+ | See [[file format]] for more details if the character in question is a Carriage Return (^M or \r). |
||
− | , 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 |
||
---- |
---- |
||
+ | ===See also:=== |
||
− | <!-- parsed by vimtips.py in 0.702139 seconds--> |
||
+ | * {{help|i_CTRL-V_digit}} (which applies also on the command-line, notwithstanding its i_ initial) about additional ways to enter a character by its hex value (below 0x100: by its hex, decimal, or octal value) |
||
+ | * to enable/disable keymaps on the command-line: {{help|'iminsert'}}, {{help|'imsearch'}}, {{help|c_CTRL-^}} |
||
+ | --[[User:Tonymec|Tonymec]] 23:38, 20 August 2009 (UTC) |
Latest revision as of 05:48, 13 July 2012
Tip 791 Printable Monobook Previous Next
created 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><C-R>" # pull unnamed buffer contents onto search (that's two presses of Control-R)
References[]
Comments[]
See file format for more details if the character in question is a Carriage Return (^M or \r).
Try ^V^M (two CTRL+keystrokes).
For cleaning up win/dos text files for *nix, there's dos2unix (aka fromdos).
See also:[]
- :help i_CTRL-V_digit (which applies also on the command-line, notwithstanding its i_ initial) about additional ways to enter a character by its hex value (below 0x100: by its hex, decimal, or octal value)
- to enable/disable keymaps on the command-line: :help 'iminsert', :help 'imsearch', :help c_CTRL-^
--Tonymec 23:38, 20 August 2009 (UTC)