我正在迁移到sublime text
并从emacs orgmode
开始降价。在markdownediting
的帮助下,sublime与markdown一样好。但我还没弄清楚如何制作TODO列表,并在TODO和DONE之间切换。有办法吗?或任何插件适用于markdownediting
?
答案 0 :(得分:3)
我为Sublime文本安装了mdTodo插件。
它有效,但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
所以我修改了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(org-mode)迁移到Sublime文本的人有所帮助。
<强>更新强>
默认快捷键 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" }
]
并在用户keybinds文件中更改它。
我把它绑定到:
{ "keys": ["ctrl+alt+d"], "command": "complete" }