 
         selectionsRanges = editor.getSelectedBufferRanges()
         # console.log(selectionsRanges[0].isEmpty())
+        # console.log(@autoSelectEntireDocument)
 
-        autoSelectEntireDocument = atom.config.get("markdown-table-formatter.autoSelectEntireDocument")
-        # console.log(autoSelectEntireDocument)
-
-        if force or (selectionsRanges[0].isEmpty() and autoSelectEntireDocument)
+        if force or (selectionsRanges[0].isEmpty() and @autoSelectEntireDocument)
             # console.log('all selected')
             selectionsRanges = [editor.getBuffer().getRange()]
 

           formattedformatline.push(newtext)
        #formatline = '|' + formattedformatline.join('|') + '|'

        if keepFirstAndLastPipes
            formatline = '|' + formattedformatline.join('|') + '|'
        else
            formatline = formattedformatline.join('|')

    #regex: /((.+?)\|)+?(.+)?\r?\n(([:\-\|]+?)\|)+?([:\-\|]+)?[ ]*(\r?\n((.+?)\|)+?(.+)?)+/mg

    constructor: ->
      @subscriptions = new CompositeDisposable
      @initConfig()
      atom.workspace.observeTextEditors (editor) =>
        @subscriptions.add editor.getBuffer().onWillSave =>
          @format editor, true if @formatOnSave

    readConfig: (key,callback) ->
      key='markdown-table-formatter.'+key
      @subscriptions.add atom.config.onDidChange key, callback
      callback
        newValue: atom.config.get(key)
        oldValue: undefined

    initConfig: () ->
      @readConfig "autoSelectEntireDocument", ({newValue}) =>
        @autoSelectEntireDocument = newValue
      @readConfig "spacePadding", ({newValue}) =>
        @spacePadding = newValue
      @readConfig "keepFirstAndLastPipes", ({newValue}) =>
        @keepFirstAndLastPipes = newValue
      @readConfig "formatOnSave", ({newValue}) =>
        @formatOnSave = newValue


    destroy: ->
        @subscriptions.dispose()
