On 24/05/12 19:20, Roy Fulbright wrote:
Date: Thu, 24 May 2012 07:56:08 -0700
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: Substitution of metacharacters
On Thursday, May 24, 2012 8:34:03 AM UTC-5, Bob von Knobloch wrote:
Hi, I've searched all over but can't find an answer. How can one perform
commands like ':%s/\n/\r\r/g' (replacing newlines or tabs etc.) in the
gui's 'find and replace' dialogue?
I tried replacing tabs, and also replacing newlines, with the GUI dialog
(Edit->Find an Replace...)
Entering \t as the "Find what" pattern and " " (two spaces) as the "Replace
with" text worked as expected, replacing all tab characters with spaces.
Entering \n as the "Find what" and '.' as the "Replace with" text also worked
as expected, joining all lines together with a '.' character in between.
Oh, I see...if a special character is in the "Replace with" text, it doesn't work as you are hoping. For
example, with "Find what" as \\t and "Replace with" as \t, the dialog does nothing. The
"Replace with" text seems to always be taken literally. The help does not really offer any information about
the behavior of the find-replace dialog (:help :promptrepl). It looks like to replace with a special character, you
somehow need to enter that special character in the dialog.
For some characters, you can do this by copy-pasting the desired literal character into
the "Replace with" text. You can get it into the clipboard from within Vim
with, for example,
:let @+="\t"
Unfortunately, this does not work for linefeed characters, and probably other
special unprintable characters will likewise not be available.
I'm not sure if there's a way to enter these characters directly in the dialog,
but likely you'll need to use the command-line rather than the dialog for
special patterns like this.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
try this:
Find what: \n
Replace with: \="\x20"
to replace all newlines with a space
Nope, the text ' \="\x20" ' gets inserted literally.
Thanks anyway,
Bob
--
The Sun is out, the sky is blue, it's time to drive the MR2.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php