Editors load file contents into memory. How that memory is stored is different for each editor but, for example purposes, you might consider it as a doubly linked list. The cursor is simply sitting at whatever node you are currently at in the list. Adding text on screen is equivalent to inserting more nodes in the linked list. For example:
/* Dashes represent links in the list */
H-o-w- -a-r-e- -y-o-u
^ /* cursor position */
If you then type the letters we , you get an update (in memory) of
H-o-w- -a-r-e- -w-e-y-o-u
^ /* cursor position */
This is obviously a simple example but illustrates the mapping from what you see in the editor window to how things may be manipulated in memory.
L7Sqr
Practically a Master Poster
657 posts since Feb 2011
Reputation Points: 201
Solved Threads: 124
If you want to insert data into an existing file you must first determine how the file is stored and then load it into memory. Once you have it in memory you can do what you want with the contents including writing them out to your own format. All of this is non-trivial with anything other than simple text files.
What exactly are you trying to do?
L7Sqr
Practically a Master Poster
657 posts since Feb 2011
Reputation Points: 201
Solved Threads: 124