How does a text editor paste text?

Suppose I wrote a letter in a notebook and I saved it as letter.txt . Then I realized that I forgot to say one thing in this letter. So I opened letter.txt with any text editor such as Notepad, Wordpad, or something like that. Now I have inserted the letters that I want to say in this letter in the middle of the file. How it works?

Example: Here is the message:

"Hi, How are you. Today I want to meet with you. Thank you.

It is actually stored in memory as follows:

"Hi, \ NHow \ 0are \ 0you. \ 0TodayToday \ 0i \ 0want \ 0to \ Nmeet \ 0you. \ NThank \ 0you.

Now I want to add I am fine after How are you . How it works? How is it added in the middle of the file? how other words are not overwritten? What is the process of doing this?

+4
source share
1 answer

For small files, text editors simply read the entire file in memory. When text is changed, the text editor changes the version in memory. Then, when saving, the text editor overwrites the original file with the new contents - therefore, the entire file is overwritten, and the text is written to the file as it is without any links or other tricks.

+1
source

Source: https://habr.com/ru/post/1395197/


All Articles