     (indent-line-to indent)))
 
 (defun ks-previous-indentation ()
-  "Get the indentation of the previous non-blank line of Kerboscript."
+  "Get the indentation of the previous non-blank, non-comment line of Kerboscript."
   (save-excursion
     (forward-line -1)
-    (while (looking-at "[[:space:]]*$")
+    (while (and (looking-at "[[:space:]]*\\(//.*\\)?$")
+                (not (bobp)))
       (forward-line -1))
     (current-indentation)))
 

        "copy" "declare" "delete" "deploy" "do" "edit" "else" "file"
        "for" "from" "function" "global" "if" "in" "is" "list" "local"
        "lock" "log" "not" "off" "or" "on" "parameter" "preserve"
        "print" "reboot" "remove" "rename" "run" "set" "shutdown"
        "step" "switch" "then" "to" "toggle" "unlock" "unset" "until"
        "volume" "wait" "when")
  "List of Kerboscript keywords for ks-mode.")

(defvar ks-types

  (let ((indentation (ks-previous-indentation))
        (significant-earlier-line nil)
        (opening-brace ".*{[[:space:]]*\\(//.*\\)?$")
        (closing-brace ".*}")
        (statement-end ".*\\.[[:space:]]*\\(//.*\\)?$")
        (blank-line "[[:space:]]*$"))
    (save-excursion
      (beginning-of-line)
