我正在从 emacs orgmode
迁移到带有 markdownediting 的 sublime text
。借助于markdownediting
,sublime 可以配合markdown。但我还没有弄清楚如何制作 TODO 列表,以及如何在 TODO 和 DONE 之间切换。有办法吗?或者任何插件都能很好地与 markdownediting
配合使用?
最佳答案
我安装了 mdTodo Sublime 文本插件。
它可以工作,但是 TODO 列表在 GitHub 上显示为公告列表(以 html 格式),看起来不太好。
我发现 GitHub 支持 orgmode
风格的 TODO 列表:
https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments
https://github.com/blog/1825-task-lists-in-all-markdown-documents
太阳系探索,1950 年代 – 1960 年代
- [ ] 水星
- [x]金星
- [x] 地球(轨道/月球)
- [x] 火星
- [ ] 木星
- [ ] 土星
- [ ] 天王星
- [ ] 海王星
- [ ] 黑利 cometd
所以我修改了 mdTodo
源代码,使其适用于 orgmode 风格的 TODO 列表。
这是我的修改:(包文件夹中的mdTodo.py)
import sublime, sublime_plugin
from datetime import datetime
class ItodoBase(sublime_plugin.TextCommand):
def run(self, edit):
filename = self.view.file_name()
# list of allowed filetypes
allowed_filetypes = ('.md', '.markdown', '.mdown')
if filename is None or not filename.endswith(allowed_filetypes):
return False
self.runCommand(edit)
class NewCommand(ItodoBase):
def runCommand(self, edit):
for region in self.view.sel():
lines = self.view.lines(region)
lines.reverse()
for line in lines:
# don't add a newline when creating new item with cursor is at an empty line
if not line:
line_contents = '-'
self.view.insert(edit, line.begin(), line_contents)
# add a newline when creating new item when cursor is at another line
else:
line_contents = self.view.substr(line) + '\n-'
self.view.replace(edit, line, line_contents)
class CompleteCommand(ItodoBase):
def runCommand(self, edit):
for region in self.view.sel():
lines = self.view.lines(region)
lines.reverse()
for line in lines:
line_head = self.view.find("- \[[x ]\]", line.begin())
line_contents = self.view.substr(line).strip()
# prepend @done if item is ongoing
if line_contents.startswith("- [ ]"):
self.view.insert(edit, line.end(), " @done (%s)" % datetime.now().strftime("%Y-%m-%d %H:%M"))
self.view.replace(edit, line_head, "- [x]")
# undo @todo
elif line_contents.startswith('- [x]'):
subfix = self.view.find('(\s)*@done(.)+\)$', line.begin())
self.view.erase(edit, subfix)
self.view.replace(edit, line_head, "- [ ]")
我希望这对那些从 Emacs(组织模式)迁移到 Sublime text 的人有所帮助。
更新
默认的快捷方式 ctrl+shift+d 与默认的 duplicate line
命令冲突。
解决方案:
path_to_sublime\Sublime Text 3\Packages\mdTodo\Default (Windows).sublime-keymap
注释掉这一行
[ // iTodo plugin
{ "keys": ["ctrl+shift+d"], "command": "complete" }
]
并在用户键绑定(bind)文件中更改它。
我把它绑定(bind)到:
{ "keys": ["ctrl+alt+d"], "command": "complete" }
关于sublimetext - 如何在 sublime text 的 markdown 中制作 "todo"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27834859/