A.J.Mechelynck wrote:
Nikolaos A. Patsopoulos wrote:
A.J.Mechelynck wrote:
Nikolaos A. Patsopoulos wrote:
Hi,
another two questions:
1. I want to delete all text that has a specific pattern. I use the following code with s command but I want to keep the \a character in the beginning:

:%s/\a,\_.\{-}<\/td><\/tr>/

To delete everything that matches a certain pattern

    :%s/pattern//g

(i.e., replace by nothing). To keep something at the start, see

    :help /\zs
    :help /\@<=


2.
how can I join lines that have non-numerical characters?

e.g.
153
Purdue
Canc Ct
1256

should be
153
Purdue Canc Ct
1256

Thanks in advance,

Nikos



(untested)

    :%g/\D.*\n.*\D/join

i.e. join two successive lines, adding an intervening space, if there is at least one non-digit anywhere in each of them.


Best regards,
Tony.

For 1 I came up with this:

:%s/\(\a\),\_.\{-}<\/td><\/tr>/\1

about 2

:%g/\D.*\n.*\D/join

.* captures some numeric values in between. Maybe sth like this would be better:

:%g/\D.*\n.*[^\d]\D/join

but this is not right.


Well, it all depends on what you want to do. If there are both digits and nondigits on a single line, do you want to join it or not? Or does it depend on whether the nondigits are or aren't whitespace?

I would suggest that you read the helpfile ":help pattern.txt" and especially the part starting at ":help pattern-overview" and extending over 150 lines or more.


Best regards,


Well that worked for me fine:

:%g/\D\n\D/join

You are right. Everything depends on what you want to do.

Another small question:

If you want to an empty line to the end of a file what does the trick?

I tried :,$s/\(.*\)/\1\n

but doesn't work

Thanks,

Nikos

Reply via email to