From 8edb3af29cd085a66b8a76010efe97e198eac109 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Wed, 10 Apr 2024 20:19:18 +0800 Subject: Add shortcuts to create todo items --- .vim/after/autoload/markdown.vim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .vim/after/autoload/markdown.vim (limited to '.vim/after/autoload/markdown.vim') diff --git a/.vim/after/autoload/markdown.vim b/.vim/after/autoload/markdown.vim new file mode 100644 index 0000000..1baac57 --- /dev/null +++ b/.vim/after/autoload/markdown.vim @@ -0,0 +1,18 @@ +let s:todo_items = ['TODO', 'DONE'] +let s:todo_items_regex = '\* \(TODO\|DONE\) ::' + +function! markdown#todo_items_set(state) abort + execute 's/' . s:todo_items_regex . '/* ' . a:state . ' ::/' +endfunction + +function! markdown#todo_items_set_next() abort + let l:line = getline('.') + + for i in range(len(s:todo_items)) + if l:line =~# ('.*\* ' . s:todo_items[i] . ' :: .*') + let l:next_todo_item_index = (i + 1) % len(s:todo_items) + let l:next_todo_item = s:todo_items[l:next_todo_item_index] + call markdown#todo_items_set(l:next_todo_item) + endif + endfor +endfunction -- cgit v1.2.3