Hi Pau, On Wed, 2006-11-22 at 11:20 +0100, Vim Visual wrote: > sorry, I got it: > > sort -k 3 > > The problem now are midnames, like > > > Mr Bla Blo > Ms Ble Blu > Dr Bli T. Blu > > but I have deleted them :)
good idea ;-) If you're going to sort based on a specific column you'll need to make sure that column holds similar data. In the eg above col3 appears to be the surname so the last row's surname is T. However, if midnames are a capital, 0 or more word characters, followed by a '.' eg C. Chris. or Christopher. %s/\(^\w\+\s\w\+\)\s\(\u\w*\.\)/\1\2/gc :%!sort -k 3 -k 2 %s/\(\u\w*\)\(\u\w*\)/\1 \2/gc similar approach if there's no '.' > > 2006/11/22, Vim Visual <[EMAIL PROTECTED]>: > > Hi, > > > > I have a text file like > > > > Mr Bla Blo > > Ms Ble Blu > > Dr Bli Blu > > etc > > > > and I would like to sort the file alphabetically after the surname > > (3rd column). How can I do that? I know how to sort it after the first > > one (visual + !sort) > > > > thanks! > > > > Pau > > -- Mark
