Sublime Forum

Change content of to-be-saved file

#1

Hey all,

I’m trying to write a plugin that basically converts a specific file between two JSON formats. Whenever I open the file, it converts the file to the human readable JSON format, en when I save it, it converts the file to the machine-friendly JSON format.

I have this working atm by using the on_pre_save hook, editing the view, and then resetting the view in the on_post_save hook. This is not ideal, since for example, the user can accidentally ctrl+z into the machine-friendly format, and I have to make work around stuff like resetting the cursor position and such.

Ideally, I would like to basically only edit the to-be-saved content of the file in the on_pre_save, without affecting the view. Does anyone know of any possible way to do this?

0 Likes