sponsor Vim development Vim logo Vim Book Ad

EDIFACT position in a segment : works out the position of the cursor in an EDIFACT segment

 script karma  Rating 3/3, Downloaded by 535  Comments, bugs, improvements  Vim wiki

created by
colin dearing
 
script type
utility
 
description
i spend quite a lot of time reading, editing, and translating EDIFACT messages.  so i have produced this to help me work out where i am in the file.

the EDIFACT position dscription
SG2.PNA.C816.3836
isnt that helpful without a spec for reference.  the first two parts (segment group 2, segment PNA) are quite clear, but the last two arent very useful.

for an example segment
PNA+PAT+NHS_NUM1:OPI+++SU:SURNAME1+FO:FORENAME1A+TI:TITLE1+MI:FORENAME1B+FS:FORENAME1C'

that is the fragment "SURNAME1"

so instead i use numbers for the element and fragment positions, both numbered from zero.  "PNA" is element zero, "PAT" element one, etc.

using this function, place your cursor in the "SURNAME1" fragment, and it will return the info:
element = 5 , fragment = 1

when using this, make sure that every segment starts on a new line in your file (search for ' and replace with '\r will do this nicely).  trying to read EDIFACT when it is all one line is just to painful, so i dont recorment it.

this function has the seperators "+" and ":" hard coded at the moment, and doesnt handle escaped seperators.
 
install details
append the file to your .vimrc
the default mapping is _=
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
get_edi_pos.vim 0.1 2002-06-10 6.0 colin dearing Initial upload
ip used for rating: 18.216.34.146

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github