Friday, July 20, 2012

Re: Remove spaces and line breaks and make single line wihtout spaces

On 20/07/12 21:06, BPJ wrote:
> On 2012-07-20 11:23, Tony Mechelynck wrote:
>> You shouldn't have used Google; use the help (Vim is the only
>> program I know which has a help worth using): see
>
> Agreed, but you still often need Google to find out where to
> look in the help system! :(
>
> /bpj
>

With Vim you don't; and if you had looked up those help tags I gave you
you would have find why: If you know (more or less) what to look for, try

:help {subject}

where {subject} is the subject, for instance i_CTRL-R for the Ctrl-R key
in Insert mode (see the various possible prefixes under ":help
help-context").

If you _don't_ know what the help topic might be, the :helpgrep command
lets you scan the whole text of all help files for a given word (or
regular expression). It is a quickfix command, see :help quickfix.txt

And as Andy Spencer (almost) said, the (not really useful) solution is

:%s/\_s//g

meaning:

:% (or :1,$) in the whole file
s :s[ubstitute] = find / replace
/ start of "find what" pattern
\_s space, tab or newline
/ start of "replace by"
/ end of "replace by", i.e., replace by nothing
g any number of times per line

And yes, like Andy said, the space between <?xml and version= should
remain, so I would replace all the above by

:2,$s/ etc., to avoid replacing in the first line.


Best regards,
Tony.
--
"You are old," said the youth, "one would hardly suppose
That your eye was as steady as ever;
Yet you balanced an eel on the end of your nose --
What made you so awfully clever?"

"I have answered three questions, and that is enough,"
Said his father. "Don't give yourself airs!
Do you think I can listen all day to such stuff?
Be off, or I'll kick you down stairs!"
-- Lewis Carrol

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