Thursday, May 24, 2012

Re: Substitution of metacharacters

On 24/05/12 15:34, 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?
>
> Many thanks,
>
> Bob
>

If the menus don't do what you want, use the keyboard. Typing

:%s/\n/\r\r

followed by Enter (no /g needed since there can be only one end-of-line
per line) will add an empty line after every line in the file. Not what
you'd want to do every day, but it ought to work.

Similarly, you can assign all that to one key by means of

:map <F2> :%s/<Bslash>n/<Bslash>r<Bslash>r<CR>

and/or

:vmap <F2> :s/<Bslash>n/<Bslash>r<Bslash>r<CR>

(the vmap would apply the substitute to all lines of the current visual
selection).

See
:help :s
:help 'magic'
:help sub-replace-special
:help map.txt


Best regards,
Tony.
--
Chism's Law of Completion:
The amount of time required to complete a government project is
precisely equal to the length of time already spent on it.

--
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

No comments:

Post a Comment