### Archive

Archive for March, 2012

## Editing GEDCOM files with vim

GEDCOM files sometimes have no indentation. That makes it difficult to read or edit them with a text editor. Using the following simple instructions, you can auto-indent the file so that it is more readable in the vim editor.

Compare the readability of the two formats

Save the next few lines into a file called gedcom_indent. Make the file executable and place it somewhere in your path.

#!/usr/bin/env python

from __future__ import print_function
import sys

for line in sys.stdin:
line = line.lstrip()
try:
level = int(line.split(' ', 1)[0])
print('\t' * level, end='')
except:
pass
print(line, end='', sep='')


autocmd BufReadPost,FileReadPost *.ged %!gedcom_indent