How to modify the buffer just before saving, and just after loading



I would like to modify the buffer just before the save, and just after the loading.

i have seen people listening to buffer event like the following. Is that the proper way ? i am not sure it respect the order

editor.getBuffer().on 'saved' , =>
  # your code goes here

how can i get the list of all signals dispatched to buffer ? maybe there are others signals more suitable than "saved"


i replaced it by the following and it seems to works

    # hook .onDidSave - reformat for view once saved
    editor.getBuffer().onDidSave =>
      console.log('did save event')


and i found the list of all signals here


If you want to modify the buffer before the save event, you might want to use TextBuffer::onWillSave instead. While the docs are not yet complete, often they contain most of the functionality already. You can find them at

Discrete events are named onDid[Verb][Noun] or onWill[Verb][Noun], for events that already happend or are about to happen, respectively. For more information take a look at the API Conventions section of this pull request.