--- /dev/null
+#!/bin/sh
+#
+# BEWARE THIS IS UGLY
+#
+# I like this approach because it imports the full documentation for each
+# setting. However, `mutt -O -D` may be much better suited for your needs.
+#
+set -eu
+
+FILE="${1:-${0%/*}/confvars}"
+TARGET="${2:-}"
+
+if [ ! -f "$FILE" ]; then
+ echo >&2 "E: File $FILE does not exist"
+ exit 1
+fi
+
+if [ -z "$TARGET" ]; then
+ TARGET="$FILE"
+fi
+
+TMPFILE="$(mktemp -t vit.XXXXXXXX)"
+cleanup() { rm -f "$TMPFILE"; trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15; }
+trap cleanup 1 2 3 4 5 6 7 8 10 11 12 13 14 15
+
+process_stanza() {
+ echo "$2"
+ local opt setting trailer
+ opt="$(sed -ne "/^set ${1}=/,/# 3\./p" $FILE)"
+ if [ -n "$opt" ]; then
+ opt="${opt%
+*}"
+ setting="${opt%%
+*}"
+ echo >&2 "Importing setting: $setting …"
+ echo "$setting"
+ echo "$opt" | grep '^#' || :
+ fi
+ echo
+ echo
+}
+
+option=
+{ zcat /usr/share/doc/neomutt/manual.txt.gz | \
+ sed -e '1,/^3\. Configuration Variables$/d;1d;/^4\./,$d' -e 's, , ,g';
+ echo END; } | \
+
+while read first rest; do
+ line="$first ${rest%% }"
+ case "$first" in
+ (3.[0-9]*|END)
+ [ -z "$option" ] || \
+ process_stanza "$option" "${stanza}"
+ stanza="# $line"
+ option="$rest"
+ ;;
+ ('')
+ stanza="${stanza:+$stanza\n}#$line"
+ ;;
+ (*)
+ stanza="${stanza:+$stanza\n}# $line"
+ ;;
+ esac
+
+done > $TMPFILE
+
+cat <<_eof > "$TARGET"
+# Auto-generated using mkconf from manual.txt
+# on $(date +'%Y-%m-%d %H:%M:%S')
+#
+# Invoked as: $0${1:+ $@}
+#
+
+$(cat "$TMPFILE")
+
+# vim:sw=12:noet:sts=12:ts=12:ft=muttrc
+_eof
+cleanup