     @titleEditor.setText(e.target.textContent)
     @urlEditor.setText(e.target.dataset.url)
 
-  insertLinkToEditor: (text, title, url) ->
+  insertLink: (text, title, url) ->
     if title
       @editor.insertText("[#{text}](#{url} '#{title}')")
     else
       @editor.insertText("[#{text}](#{url})")
 
-  getSavedLink: (text) ->
-    @links?[text.toLowerCase()]
+  removeLink: (text) ->
+    @editor.insertText(text)
 
   setLink: (text, url, title) ->
     @textEditor.setText(text)
     @urlEditor.setText(url)
     @titleEditor.setText(title)
 
-  saveLink: (text, title, url) ->
+  getSavedLink: (text) ->
+    @links?[text.toLowerCase()]
+
+  isChangedSavedLink: (link) ->
+    savedLink = @getSavedLink(link.text)
+    savedLink and (savedLink.title != link.title or savedLink.url != link.url)
+
+  updateSavedLink: (text, title, url) ->
     try
-      @links[text.toLowerCase()] = title: title, url: url
-      CSON.writeFileSync(@getLinkPath(), @links)
+      if @saveCheckbox.prop("checked")
+        @links[text.toLowerCase()] = title: title, url: url if url
+      else if not @isChangedSavedLink(text: text, title: title, url: url)
+        delete @links[text.toLowerCase()]
+      CSON.writeFileSync(@getSavedLinksPath(), @links)
     catch error
       console.log(error.message)
 
-  loadLinks: ->
+  loadSavedLinks: ->
     try
-      file = @getLinkPath()
+      file = @getSavedLinksPath()
       if fs.existsSync(file)
         @links = CSON.readFileSync(file)
       else

    if utils.isLink(selection)
      link = utils.parseLink(selection)
      @setLink(link.text, link.url, link.title)
    else if @getSavedLink(selection)
      link = @getSavedLink(selection)
      @setLink(selection, link.url, link.title)
      @saveCheckbox.prop("checked", true)

  updateSearch: ->
    return unless @posts

    catch error
      console.log(error.message)

  getSavedLinksPath: ->
    atom.project.resolve(atom.config.get("md-writer.siteLinkPath"))

  fetchPosts: ->
