diff --git includes/base.inc includes/base.inc
index d081c89..8415409 100644
--- includes/base.inc
+++ includes/base.inc
@@ -125,4 +125,69 @@ class views_object {
       unset($this->query);
     }
   }
+
+  function export_options($indent, $prefix) {
+    $output = '';
+    foreach ($this->option_definition() as $option => $definition) {
+      $output .= $this->export_option($indent, $prefix, $this->options, $option, $definition, array());
+    }
+
+    return $output;
+  }
+
+  function export_option($indent, $prefix, $storage, $option, $definition, $parents) {
+    // Do not export options for which we have no settings.
+    if (!isset($storage[$option])) {
+      return;
+    }
+
+    if (isset($definition['export'])) {
+      if ($definition['export'] === FALSE) {
+        return;
+      }
+
+      // Special handling for some items
+      if (method_exists($this, $definition['export'])) {
+        return $this->{$definition['export']}($indent, $prefix, $storage, $option, $definition, $parents);
+      }
+    }
+
+    // Add the current option to the parents tree.
+    $parents[] = $option;
+    $output = '';
+
+    // If it has child items, export those separately.
+    if (isset($definition['contains'])) {
+      if (!is_array($definition['contains'])) {
+        dsm($definition['contains']);
+      }
+      foreach ($definition['contains'] as $sub_option => $sub_definition) {
+        $output .= $this->export_option($indent, $prefix, $storage[$option], $sub_option, $sub_definition, $parents);
+      }
+    }
+    // Otherwise export just this item.
+    else {
+      $default = isset($definition['default']) ? $definition['default'] : NULL;
+
+      if ($storage[$option] !== $default) {
+        $output .= $indent . $prefix . "['" . implode("']['", $parents) . "'] = ";
+        if (isset($definition['bool'])) {
+          $output .= empty($storage[$option]) ? 'FALSE' : 'TRUE';
+        }
+        else {
+          if (is_array($storage[$option])) {
+            foreach ($storage[$option] as $sub_option => $sub_definition) {
+              $output .= $this->export_option($indent, $prefix, $storage[$option], $sub_option, $sub_definition, $parents);
+            }
+          }
+          else {
+            $item = views_var_export($storage[$option], $indent);
+          }
+        }
+
+        $output .= ";\n";
+      }
+    }
+    return $output;
+  }
 }
diff --git includes/view.inc includes/view.inc
index 669d8c5..d4eed7a 100644
--- includes/view.inc
+++ includes/view.inc
@@ -1373,6 +1373,8 @@ class view extends views_db_object {
         continue;
       }
 
+      $output .= $display->handler->export_options($indent, '$handler->options');
+/*
       foreach ($display->handler->option_definition() as $option => $definition) {
         // Special handling for some items
         switch ($option) {
@@ -1395,6 +1397,7 @@ class view extends views_db_object {
             }
         }
       }
+*/
     }
 
     return $output;
diff --git plugins/views_plugin_display.inc plugins/views_plugin_display.inc
index cd1b428..24254c2 100644
--- plugins/views_plugin_display.inc
+++ plugins/views_plugin_display.inc
@@ -278,6 +278,7 @@ class views_plugin_display extends views_plugin {
           'arguments' => TRUE,
           'filters' => TRUE,
         ),
+        'export' => FALSE,
       ),
       'relationships' => array(
         'default' => array(),
@@ -2073,6 +2074,46 @@ class views_plugin_display extends views_plugin {
     }
   }
 
+  function export_option($indent, $prefix, $storage, $option, $definition, $parents) {
+    $output = '';
+    if (!$parents && !$this->is_default_display()) {
+      // Do not export items that are not overridden.
+      if ($this->is_defaulted($option)) {
+        return;
+      }
+
+      // If this is not defaulted and is overrideable, flip the switch to say this
+      // is overridden.
+      if ($this->defaultable_sections($option)) {
+        $output = $indent . $prefix . "['defaults']['$option'] = FALSE;\n";
+      }
+    }
+    $output .= parent::export_option($indent, $prefix, $storage, $option, $definition, $parents);
+    return $output;
+  }
+
+  function export_item($indent, $prefix, $storage, $option, $definition, $parents) {
+    $output = '';
+
+    // cut the 's' off because the data is stored as the plural form but we need
+    // the singular form. Who designed that anyway? Oh yeah, I did. :(
+    $type = substr($option, 0, -1);
+    foreach ($storage[$option] as $id => $info) {
+      $handler = views_get_handler($info['table'], $info['field'], $type);
+      if ($handler) {
+        $handler->init($this->view, $info);
+        $output .= $indent . $prefix . "['$option']['$id']['id'] = '$id';\n";
+        $output .= $indent . $prefix . "['$option']['$id']['table'] = '$info[table]';\n";
+        $output .= $indent . $prefix . "['$option']['$id']['field'] = '$info[field]';\n";
+        $output .= $handler->export_options($indent, $prefix . "['$option']['$id']");
+      }
+
+      // Prevent reference problems.
+      unset($handler);
+    }
+
+    return $output;
+  }
 }
 
 
