[Techtalk] RegEx problem in vim

Tricia Bowen tricia.bowen at gmail.com
Mon Jul 26 15:06:50 EST 2004


You might want to try this pattern to replace the space or newline at
the same time:

:%s/\([A-Z]\)\([ \n]\)/\1.\2/g

On Mon, 26 Jul 2004 20:17:24 +0200, Gebhard Dettmar
<gebhard.dettmar at student.hu-berlin.de> wrote:
> Hi everyone,
> I have a phd-thesis to format according to a Mouton de Gruyter
> template (.dot ;-(
> In the bibliography everything is like
> ---snip---
> Eiselen, W M [1934]
>        1967    Christianity and the religious life of the Bantu. In
> Schapera, I (ed), Western civilization and the
> natives of South Africa. London: Routledge and Kegan Paul.
> ---snap---
> Of course the first name-initials must be abbreviated with a dot
> So I saved the bibliography as a text + line breaks file, deleted DOS
> carriage returns (learned from my last problem ;-)
> and wrote in vim:
> :%s/\([A-Z]\) /\1. /g
> which means, (or at least is intended to ;-): any capital letter
> followed by a space is to be substituted by this letter + dot + space
> He matches 351 Characters
> Now the Capitals letters followed by a newline are left.
> when I write :%s/\([A-Z]\)\n/\1.\n
> he matches 250 characters but deletes the newline, which I want to
> keep. So he recognizes the newline in the search-part but ignores in
> the substitute-part. What am I doing wrong here?
> Any help would be appreciated
> Thanks in advance
> Gebhard
> 
> _______________________________________________
> Techtalk mailing list
> Techtalk at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/techtalk
> 


-- 
--Tricia


More information about the Techtalk mailing list